[ Java ] [ Spring ] Spring 一些配置项 及 <context:annotation-config/> 專文解释说明

節錄重點:

@ Resource 、@ PostConstruct、@ PreDestro、@PersistenceContext、@Required 都必須聲明相關的 bean

所以如果總是需要按照傳統的方式一條一條配置顯得有些繁瑣和沒有必要,於是spring給我們提供<context:annotation-config/>的簡化配置方式,自動幫你完成聲明。

但使用註解一般都會配置掃瞄包路徑選項

<context:component-scan base-package=」XX.XX」/> 

該配置項其實也包含了自動注入上述processor的功能,因此當使用 <context:component-scan/> 後,就可以將 <context:annotation-config/> 移除了。

 

原文出處:

http://mushiqianmeng.blog.51cto.com/3970029/723880

 

英文:

How to use

http://howtodoinjava.com/spring/spring-core/how-to-use-spring-component-repository-service-and-controller-annotations/

 

Difference Between @Component, @Service, @Repository and @Controller:

http://javapapers.com/spring/spring-component-service-repository-controller-difference/

 

posted @ 2017-03-02 09:08  Vincent Lee  阅读(122)  评论(0编辑  收藏  举报