annotation-config vs(对比) component-scan

阅读更多
可以处理@Autowired,但是不能处理@Component, @Service, @Repository 所以如果你使用了@Component, @Service, @Repository就必须添加.

包含了的功能,并且还可以处理@Component, @Service, @Repository, 所以你只要使用了
就不需要添加

http://techidiocy.com/annotation-config-vs-component-scan-spring-core/

annotation-config :  Annotation config main job is to activate all the annotations that are present in java beans and those are already registered either by defining in your application context file or being registered while component scanning. Important point is they need to be registered.

component-scan : Component scan can do everything that annotation config does , in addition to it it also registers the java classes as spring bean those are annotated with @Component , @Service ,@Repository etc.

你可能感兴趣的:(spring,annotation,component,scan,config)