Reputation: 14879
Currently my spring configurations are in a xml file (the traditionaly way).
One thing that i like about this is during deployment I can deploy a different version that has my production settings, or say in a test environment I can have test settings there.
I like the idea of having things configured in a class, but that will get compiled into my war and then it won't be as flexible.
Is there a way around this?
Upvotes: 2
Views: 567
Reputation: 7952
The spring reference manual includes a section on combining both Java and XML configuration. See http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/beans.html#beans-java-combining
If you tend to be more XML centric you can bootstrap your app using XML and then introduce Java config as needed in an ad-hoc fashion. This might be a good way to ease into it. You might decide to go Java config all the way.
Upvotes: 0
Reputation: 340693
Java configuration is great and it has several advantages:
refactoring-friendly
type-safety
much more flexible (you can write any Java code, not being bound to XML semantics and capabilities).
I can deploy a different version that has my production settings, or say in a test environment I can have test settings there.
Investigate Spring @Profile
s. They are orthogonal to your question (work both in XML and @Configuration
) but are best suited in your situation.
Upvotes: 4
Reputation: 66637
Those are the only two ways available. If you don't want configuration baked in code, then you have to go with xml.
Upvotes: 0