spring注解中@component是什么意思
@Component("userManager")
public class UserManagerImpl implements UserManager {
private UserDao userDao;
public UserDao getUserDao() {
return userDao;
}
@Resource
public void setUserDao(UserDao userDao) {
this.userDao = userDao;
}
/*
* (non-Javadoc)
*
* @see
* com.wjs.registration.service.UserManager#exists(com.wjs.registration.
* model.Users)
*/
public boolean exists(Users u) {
return userDao.checkUserExistsWithName(u.getUsername());
}
/*
* (non-Javadoc)
*
* @see
* com.wjs.registration.service.UserManager#add(com.wjs.registration.model
* .Users)
*/
public void add(Users u) {
userDao.save(u);
}
}
在持久层、业务层和控制层分别採用 @Repository、@Service 和 @Controller 对分层中的类进行凝视,而用 @Component 对那些比較中立的类进行凝视
这里就是说把这个类交给Spring管理,又一次起个名字叫userManager,因为不好说这个类属于哪个层面。就用@Component
spring注解中@component是什么意思的更多相关文章
- 关于Spring注解 @Service @Component @Controller @Repository 用法
@Component 相当于实例化类的对象,其他三个注解可以理解为@Component的子注解或细化. 在annotaion配置注解中用@Component来表示一个通用注释用于说明一个类是一个spr ...
- Spring注解之@Component详细解析
@controller 控制器(注入服务) 2.@service 服务(注入dao) 3.@repository dao(实现dao访问) 4.@component (把普通pojo实例化到sprin ...
- Spring注解之@Component、@Controller、@Service、@Repository
目录 1.使用这四个注解的前提 2.详解@Component 3. @Service("XXX")或者@Service(value = "XXX")情况 4.总 ...
- spring注解(Component、依赖注入、生命周期、作用域)
1.注解 注解就是一个类,使用@加上注解名称,开发中可以使用注解取代配置文件 2.@Component 取代<bean class="">,@Component 取代 ...
- spring注解中使用properties文件
一.只读取单个 properties 文件 1.在 spring 的配置文件中,加入 引入命名空间: xmlns:util="http://www.springframework.org/s ...
- Spring 注解中@Resource 和 @Authwired 的区别
@Resource的作用相当于@Autowired,只不过@Autowired按byType自动注入,而@Resource默认按 byName自动注入罢了.@Resource有两个属性是比较重要的,分 ...
- Spring注解的步骤
Spring框架提供DI(属性注解)和IOC(类/Bean的注解)注解. 注解:标注.注入和解析.解释;标注和解释一部分代码的作用在框架中:就是配置文件的另外一种实现方式@Type.@Taget;减少 ...
- 跟Evan学Sprign编程思想 | Spring注解编程模式【译】
Spring注解编程模式 概况 多年来,Spring Framework不断发展对注解.元注解和组合注解的支持. 本文档旨在帮助开发人员(Spring的最终用户以及Spring Framework和S ...
- Spring中@Component注解,@Controller注解详解
在使用Spring的过程中,为了避免大量使用Bean注入的Xml配置文件,我们会采用Spring提供的自动扫描注入的方式,只需要添加几行自动注入的的配置,便可以完成 Service层,Controll ...
随机推荐
- crm 系统项目(三) 业务
1. 项目背景 crm系统是某教育平台正在使用的项目,系统主要为 销售部.运营部.教质部门提供管理平台,随着公司规模的扩展,对公司员工的业务信息量化以及信息化建设越来越重要. crm系统为不同角色的用 ...
- 【codeforces 229C】Triangles
[题目链接]:http://codeforces.com/problemset/problem/229/C [题意] 给你一张完全图; 然后1个人从中选择m条边; 然后另外一个人从中选择剩余的n*(n ...
- 3.is null和is not null
3.WHERE中使用is null和is not null //查询工资是null空值的人 select * from person where salary is null; //查询工 ...
- DataTables warning: table id=dataTable - Requested unknown parameter 'acceptId' for row 0. For more
重点内容 DataTables warning: table id=dataTable - Requested unknown parameter 'acceptId' for row 0. For ...
- leetCode(46):Kth Smallest Element in a BST
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Not ...
- node08---EJS模版
四.模板引擎 <a href="<%= url %>"><img src="<%= imageURL %>" alt= ...
- chrome的F12的inspect使用
chrome中查看cookie https://stackoverflow.com/questions/10014996/how-do-you-check-cookies-using-chrome T ...
- pip更新问题
pip更新及Requirement already up-to-date解决方法 pip更新 更新命令 将pip更新版本 1 python -m pip install --upgrade pip R ...
- BigDecimal相除异常
使用两个BigDecimal类型的数字做除法运算时,出现了一个如下的异常信息: 1 java.lang.ArithmeticException: Non-terminating decimal exp ...
- vs2015汉化
VS2015汉化 VS2015安装打开后默认是英文的,将它改成中文的VS 1.安装下载好的语言包进行安装 2.正在安装 3.安装完成后关闭 4.打开VS2015默认不是中文的,点击Tools--> ...