解释:

@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. Unity Toast插件(UGUI版)

    简介 介于自己之前经历的一些开发过程,非常希望unity能有类似Toast的功能用于一些简单的信息显示.但是找来找去找了半天,都木有发现,实在是憋不住了,自己写了个,感觉还可以用,发出来共享一下... ...

  2. [ CTSC 2007 / BZOJ 2151 ] Backup / 种树

    \(\\\) \(Description\) 给出一个数轴上\(N\)个点的坐标\(A_i\),选择\(K\)个点对,使得这\(K\)个点对每个点对的距离之和尽可能小. \(N\in [0,10^5] ...

  3. js基础---元素操作时字符串拼接

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  4. 编写高质量的js之恰当选用if和switch

    switch结构中存在很多限制,存在这些限制的主要目的是提高多重分支结构的执行效率.因此,如果能够使用switch结构,就不要选择if结构. 无论是使用if结构,还是使用switch结构,应该确保下面 ...

  5. 使用FastReport的BarCode2D控件生成含中文的PDF417条形码

    解决方法:设定CodePage为936 FastReport用户手册中关于CodePage的说明: CodePage This property is specific to the PDF417 a ...

  6. (转)Struts2访问Servlet的API及......

    http://blog.csdn.net/yerenyuan_pku/article/details/67315598 Struts2访问Servlet的API 前面已经对Struts2的流程已经执行 ...

  7. parseInt()函数

    parseInt()转化整形是从左往右,取出第一个整型,如:10a10b,则显示10: //20170719补充 如果该字符串第一个字符是0,那么该字符串会基于八进制而非十进制来求值,在八进制中,8和 ...

  8. JSON数据 与 JSON数据的使用

    https://blog.csdn.net/u010378878/article/details/52943792 https://blog.csdn.net/liuxuan12417/article ...

  9. git学习(1)

    一.git fetch 和git pull 的差别 1.git fetch 相当于是从远程获取最新到本地,不会自动merge,如下指令: git fetch orgin master //将远程仓库的 ...

  10. vue移动端地址三级联动组件(二)

    继续上一篇: 子组件css: <style scoped lang="less"> #city { width: 100%; height: 100%; positio ...