Question

I have been in the process of upgrading a Spring MVC app that was using Framework 2.5.6, Security 2.0.4, and Web Services 1.5. In researching the newer versions, I've realized that Spring 3.1.0 and 3.0.7 deprecate the inheritance for controllers in favor of annotation driven configuration. I understand that annotations are the way forward with Spring configuration but in my situation the people who will be configuring default values for dependency injection cannot edit src files.

The process at my company is like this:

  • I am the main developer for the Java EE app.
  • We have another team of designers and less-skilled developers who customize jsp, css, (some) javascript, xsl, the XML Spring configuration, and the Spring properties files.
  • We have over 100 active custom implementations, each with different default values to be injected into beans and some with i18n messaging.
  • Instead of having 100s of different themes in our core product, we have a very smart build process that allows our 'customization team' to maintain the custom applications within their own source control system. The build script will overwrite any files from the custom application to the core application before compiling and deploying to Tomcat. Therefore, src files are never touched, decoupling the engineering from the aesthetics within our company.

(If I had a chance to build a configuration module into the app, it would have already been done. So for now we're stuck with managing XML configurations.)

So how would an annotation configuration work in my case? It seems to me like it is not a feasible solution given the architecture of our product. Isn't the main goal of annotation-driven configuration to have the developer manage dependency injection within src files instead of XML files?

Does anyone know a way to have only XML configuration in Spring 3?

EDIT: I found this: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-java-combining so I think I can migrate all the controllers to use annotations but leave other beans as they are since controller configurations are not touched very often by our customization team.

Was it helpful?

Solution

i'm not a great expert on this, but i am using spring 3.1 in a current project and there's still plenty of xml configuration: the application as a whole is assembled from a bunch of beans defined in foo-servlet.xml (so i have daos that are plugged into controller beans etc). my controllers certainly have annotations on the methods associated with incoming HTTP requests, but they are for things like URL parameters - the kind of details that are tightly tied to the code. and i use annotation and type-driven injection in tests because it's quick and easy.

so i'm a bit confused reading your question. it's possible i am misunderstanding, or my case is different, but it sounds a bit like you're over-estimating how much you need to use annotations. i use them where it seems to make sense, but stick with xml where that seems best...

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