Question

What are the significant differences defining spring configurations (beans and datasources) in Java using the @Configuration Annotation instead of XML config files. Matter of taste or is there more?

Was it helpful?

Solution

The most important difference between XML and Java config is that you have to recompile your java configuration if it changes.

With XML, you can (though you shouldn't, but maybe for hotfixes) just edit the file and add something, for example, a logger, a filter, other bean, etc., and just restart your application.

With Java, you would have to edit the source code, recompile either only the configuration .java files or the whole project and redeploy it.

Otherwise, it's a matter of taste. You can (or will be able to in 4.0) do everything in XML or everything in Java or mix it up.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top