http://stackoverflow.com/questions/11903053/difference-between-component-and-configuration-in-spring-3
@Configuration
is the heart of the Java-based configuration mechanism that was introduced in Spring 3. It provides an alternative to XML-based configuration.
So the 2 following snippets are identical:
<beans ...>
<context:component-scan base-package="my.base.package"/>
... other configuration ...
</beans>
and:
@Configuration
@ComponentScan(basePackages = "my.base.package")
public class RootConfig {
... other configuration ...
}
In both cases Spring will scan in
my.base.package
and below for classes annotated with @Component
or one of the other annotations that are meta-annotated with @Component
such as @Service
.
No comments:
Post a Comment