Spring注解 @Component、@Repository、@Service、@Controller @Resource、@Autowired、@Qualifier 解析
@Repository、@Service、@Controller 这几个是一个类型,其实@Component 跟他们也是一个类型的
Spring 2.5 中除了提供 @Component 注释外,还定义了几个拥有特殊语义的注释,它们分别是:@Repository、@Service和 @Controller 其实这三个跟@Component 功能是等效的
@Service用于标注业务层组件(我们通常定义的service层就用这个)
@Controller用于标注控制层组件(如struts中的action)
@Repository用于标注数据访问组件,即DAO组件
@Component泛指组件,当组件不好归类的时候,我们可以使用这个注解进行标注。
@Resource、@Autowired、@Qualifier
@Resource("") 可设置别名 默认名重名的时候可以用
@Autowired 不支持设置别名 可以跟@Qualifier("alias") 配合使用
参考了http://www.ulewo.com/user/10001/blog/273
Spring注解 @Component、@Repository、@Service、@Controller @Resource、@Autowired、@Qualifier 解析的更多相关文章
- SpringAnnotation注解之@Component,@Repository,@Service,@Controller
@Component:组件,表示此写上了此注解的bean,作为一个组件存在于容器中.这样的话别的地方就可以使用@Resource这个注解来把这个组件作为一个资源来使用了.初始化bean的名字为类名首字 ...
- @Component @Repository @Service @Controller
Spring 2.5 中除了提供 @Component 注释外,还定义了几个拥有特殊语义的注释,它们分别是:@Repository.@Service 和 @Controller.在目前的 Spring ...
- 从头认识Spring-2.7 自己主动检測Bean(1)-@Component @Repository @Service @Controller
这一章节我们来讨论一下自己主动检測Bean. 1.domain 厨师类: package com.raylee.my_new_spring.my_new_spring.ch02.topic_1_19; ...
- Spring 注解@Component,@Service,@Controller,@Repository
Spring 注解@Component,@Service,@Controller,@RepositorySpring 2.5 中除了提供 @Component 注释外,还定义了几个拥有特殊语义的注释, ...
- [转]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 ...
- What's the difference between @Component, @Repository & @Service annotations in Spring?
@Component is equivalent to <bean> @Service, @Controller , @Repository = {@Component + some mo ...
- Spring注解Component原理源码解析
在实际开发中,我们经常使用Spring的@Component.@Service.@Repository以及 @Controller等注解来实现bean托管给Spring容器管理.Spring是怎么样实 ...
- 【转载】@Component, @Repository, @Service的区别
@Component, @Repository, @Service的区别 官网引用 引用spring的官方文档中的一段描述: 在Spring2.0之前的版本中,@Repository注解可以标记在任何 ...
- Spring注解@Component、@Repository、@Service、@Controller,@Autowired、@Resource用法
一.Spring定义bean,@Component.@Repository.@Service 和 @Controller Spring 2.5 中除了提供 @Component 注释外,还定义了几个拥 ...
- Spring注解@Component、@Repository、@Service、@Controller @Resource、@Autowired、@Qualifier、@scope
以下内容摘自部分网友的,并加上了自己的理解 @Service用于标注业务层组件(我们通常定义的service层就用这个) @Controller用于标注控制层组件(如struts中的action.Sp ...
随机推荐
- 伟景行 citymaker 从入门到精通(2)——工程图层树加载
工程树是指explorer左边这棵树 本例子实现了图层树加载,点击节点切换可视状态 树控件使用easyui的树 html部分 onCheck:treeProjectTreeOnCheck是指树节点的o ...
- Scala 学习记录(一)
1. 相对于java,scala的值修饰用val,变量修饰用var.值相当于java的final 修饰了. package demo object ScalaBase extends App { pr ...
- 在CentOS上把Git从1.7.1升级到1.7.12.4
在CentOS上把Git从1.7.1升级到1.7.12.4 摘要:本文记录了在CentOS 6.3上,把Git从1.7.1升级到1.7.12.4的过程. 1. 概述 在我做的一个项目中,最近我对生产服 ...
- JQuery日期选择器插件date-input
JQuery日期选择器插件之date-input 官方网站:http://jonathanleighton.com/projects/date-input/ 下载地址: http://github.c ...
- JDBC性能优化篇
系统性能. 少用Metadata方法 与其它的JDBC方法相比, 由ResultSet对象生成的metadata对象的相对来说是很慢的. 应用程序应该缓存从ResultSet返回的metada ...
- Java三大特性之封装
.封装 1.概念:把对象的内部细节封闭起来,只提供操作对象属性的公共方法. 封装是面向对象编程语言对客观世界的模拟:如:电视机,她的内部元件就被封闭起来了,仅仅暴露电视机按钮来供人使用,这样就没有人能 ...
- Gym - 100676G Training Camp (状压dp)
G. Training Camp[ Color: Yellow ]Montaser is planning to train very hard for ACM JCPC 2015; he has p ...
- Promise 理解与使用
个人觉得这篇博客写的非常详细且易懂,推荐给小伙伴们~ https://www.cnblogs.com/lvdabao/p/es6-promise-1.html#!comments
- css--字体和文本样式
文字样式属性 字体:font-family 文字大小:font-size 文字颜色:font-color 文字粗细:font-weight 文字样式:font-style font-family字体属 ...
- HDU-5253-链接的管道
http://acm.hdu.edu.cn/showproblem.php?pid=5253 #include <iostream> #include <bits/stdc++.h& ...