Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate full XML configuration from Spring 3 annotations

Is there is a way to generate full XML configuration file based on Spring 3 annotations scattered all over the classes?

Ideally, I'm looking for a tool that can "parse" a Spring 3 project and output XML configuration, something like xdoclet was doing (but off course from Spring annotations)

Is there a tool like this, or a way I could write my own if none exists?

like image 562
ElenaT Avatar asked Apr 21 '11 19:04

ElenaT


People also ask

How do you do annotation based configuration in XML Spring?

Starting from Spring 2.5 it became possible to configure the dependency injection using annotations. So instead of using XML to describe a bean wiring, you can move the bean configuration into the component class itself by using annotations on the relevant class, method, or field declaration.

Can we use both annotation and XML based configuration?

Java and XML configuration are not exclusive - both can be used inside the same Spring application. In order to retrieve a bean from an XML file, one has to use the Spring container. As mentioned, one can achieve this with @ExternalBean annotation (the recommended way).

Are annotations better than XML for configuring Spring?

XML configurations can take a lot of work when there are a lot of beans, while annotations minimize the XML configurations. Annotation injection is performed before XML injection. Thus, XML configurations will override that of the annotations.


1 Answers

You can always write your own. I'm not aware of one.

Funny, because annotations were added because some people complained about heavy XML configuration. You're swimming against the tide here.

Just curious - why do you want the XML now? Why aren't the annotations sufficient?

like image 135
duffymo Avatar answered Jan 02 '23 11:01

duffymo