Bootstrapping a web application with Spring 3.1 and Java based Configuration, part 1 - DZone Java
First, the @Configuration annotation – this is the main artifact used by the Java based Spring configuration; it is itself meta-annotated with @Component, which makes the annotated classes standard beans and as such, also candidates for component scanning. The main purpose of @Configuration classes is to be sources of bean definitions for the Spring IoC Container. For a more detailed description, see the official docs.
Then, @ImportResource is used to import the existing XML based Spring configuration. This may be configuration which is still being migrated from XML to Java, or simply legacy configuration that you wish to keep. Either way, importing it into the Container is essential for a successful migration, allowing small steps without to much risk. The equivalent XML annotation that is replaced is:
<import resource="classpath*:/rest_config.xml" />
Read full article from Bootstrapping a web application with Spring 3.1 and Java based Configuration, part 1 - DZone Java
No comments:
Post a Comment