@repository注解

来源:互联网 发布:js是什么文件格式 编辑:程序博客网 时间:2024/06/05 14:42

dao层使用@repository注解


@Repository(value="userDao")注解是告诉Spring,让Spring创建一个名字叫“userDao”的UserDaoImpl实例。
当Service需要使用Spring创建的名字叫“userDao”的UserDaoImpl实例时,就可以使用@Resource(name = "userDao")注解告诉Spring,Spring把创建好的userDao注入给Service即可。

@Autowired可以对成员变量、方法和构造函数进行标注,来完成自动装配的工作,我们也要清楚,@Autowired是根据类型进行自动装配的。


原创粉丝点击