解释:

@Controller 声明Action组件

@Service   声明Service组件    @Service("myMovieLister") 

@Repository 声明Dao组件

@Autowired 用于注入


配置方位:

@Repository ->(XXDaoImpl)
,
@Service("UserService")->(XXServiceImpl)
@Autowired ->(private UserDao;) 



注意事项:

注解来注入bean实现对象的实例化时,加了@Repository 或是 @Service("UserService")的类中不能出现类成员变量的在创建时进行实例化。

比如:private UserDao dao = new UserDao();

不然会出现 Error creating bean with name 'userController': Injection of autowired dependencies failed; 之类导致相关bean实例化的失败错误。

@Repository @Service 和@Autowired 的使用的更多相关文章

  1. 【Infomatica】Infomatica PowerCenter 9.1.0配置Repository Service和Integration Service小结

    2014-05-14 今天在虚拟机中尝试安装Infomatica PowerCenter 9.1.0. 安装环境:Windows Server 2003 32bit. 字符集环境 DBMS:Oracl ...

  2. SpringAnnotation注解之@Component,@Repository,@Service,@Controller

    @Component:组件,表示此写上了此注解的bean,作为一个组件存在于容器中.这样的话别的地方就可以使用@Resource这个注解来把这个组件作为一个资源来使用了.初始化bean的名字为类名首字 ...

  3. 关于ASP.NET MVC+Repository+Service架构的一些思考

    看了一些ASP.NET MVC开源项目后的一些想法,关于ASP.NET MVC+Repository+Service架构的一些思考 最近在学习ASP.NET MVC 2.0的一些开源项目,发现这些项目 ...

  4. [转]what’s the difference between @Component ,@Repository & @Service annotations in Spring

    原文地址:https://www.cnblogs.com/softidea/p/6070314.html @Component is equivalent to <bean> @Servi ...

  5. What's the difference between @Component, @Repository & @Service annotations in Spring?

    @Component is equivalent to <bean> @Service, @Controller , @Repository = {@Component + some mo ...

  6. 【转载】@Component, @Repository, @Service的区别

    @Component, @Repository, @Service的区别 官网引用 引用spring的官方文档中的一段描述: 在Spring2.0之前的版本中,@Repository注解可以标记在任何 ...

  7. @Component @Repository @Service @Controller

    Spring 2.5 中除了提供 @Component 注释外,还定义了几个拥有特殊语义的注释,它们分别是:@Repository.@Service 和 @Controller.在目前的 Spring ...

  8. @Component, @Repository, @Service,@Controller的区别

    @Component, @Service, @Controller, @Repository是spring注解,注解后可以被spring框架所扫描并注入到spring容器来进行管理 @Componen ...

  9. @Component, @Repository, @Service的区别

    注解 含义 @Component 最普通的组件,可以被注入到spring容器进行管理 @Repository 作用于持久层 @Service 作用于业务逻辑层 @Controller 作用于表现层(s ...

随机推荐

  1. 关于 android屏幕适配

    一.关于布局适配 1.不要使用绝对布局 2.尽量使用match_parent 而不是fill_parent . 3.能够使用权重的地方尽量使用权重(android:layout_weight) 4.如 ...

  2. Java系列学习(十三)-字符串

    1.字符串基础 概念:字符串本质是打包字符数组的对象,是java.lang.String类的实例 2.字符串的构造方法 public String() public String(byte[] byt ...

  3. Android开发初体验

    本文通过开发一个应用来学习Android基本概念及构成应用的UI组件. 开发的应用名叫GeoQuiz,它能给出一道道地理知识问题.用户点击true或false按钮回答问题,应用即时做出反馈 第一步请先 ...

  4. jQuery——尺寸位置

    获取宽:$(".box").width() 设置宽:$(".box").width(200) 获取高:$(".box").height() ...

  5. C#——数据库的访问

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  6. java攻城师之路--复习java web之request_respone

    Servlet技术 两条主线1.HTTP协议 2.Servlet生命周期 init() 方法中参数 ServletConfig 对象使用通过ServletConfig 获得 ServletContex ...

  7. strut2 拦截器 使用

    拦截器是strut2里一个很振奋人心的应用.通过配置拦截器可以在action执行之前进行一些初始化或者是其他的操作,但是在action执行之后,返回结果就已经确定,结果是很难改变了(目前我还不知道怎么 ...

  8. Tcl之looping

    1 While loop while test body The while command evaluates test as an expression. If test is true, the ...

  9. Caffe2:ubuntu修改链接方式ln

    参考:文件和目录命令-文件重定向 ln 使用caffe2,产生了此种情况: from caffe2.python import workspace >>WARNING:root:This ...

  10. 错误处理:vmware下克隆centos7配置静态ip地址网卡问题

    vmware下克隆centos7,在配置静态ip地址,重启网卡存在问题,还是mac地址问题 ip addr show 查看下mac地址,配置文件修改下,重启网卡正常了