//,首先使用,@Repository 将,DAO 类声明为,Bean ,package bookstore.dao; ,@Repository ,public class  UserDaoImpl implements  UserDao {,……,},//大敌;其次,在,XML 配置文件中启动,Spring 的自动扫描功能 ,& lt; beans …,在, ,,,…… ,& lt;上下文:component-scan 基础包=癰ookstore.dao”,/祝辞, ...... & lt;/beans>大敌; , @ service, @ component, @Constroller,它们分别用于软件系统的不同层次: @Component 是一个泛化的概念,仅仅表示一个组件,(Bean),可以作用在任何层次。 @Service 通常作用在业务层,,但是目前该功能与,@Component 相同。 @Constroller 通常作用在控制层,但是目前该功能与,@Component 相同。