spring注解中@component是什么意思@Component("userManager")public class UserManagerImpl implements UserManager {private UserDao userDao ;public UserDao getUserDao() {return userDao;}@Resource public void setUserDao(UserDao userDao) {this.userDa

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 21:38:19
spring注解中@component是什么意思@Component("userManager")publicclassUserManagerImplimplementsUserManager{pri

spring注解中@component是什么意思@Component("userManager")public class UserManagerImpl implements UserManager {private UserDao userDao ;public UserDao getUserDao() {return userDao;}@Resource public void setUserDao(UserDao userDao) {this.userDa
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);
}
}
这里表示什么意思哦@Component("userManager")

spring注解中@component是什么意思@Component("userManager")public class UserManagerImpl implements UserManager {private UserDao userDao ;public UserDao getUserDao() {return userDao;}@Resource public void setUserDao(UserDao userDao) {this.userDa
在持久层、业务层和控制层分别采用 @Repository、@Service 和 @Controller 对分层中的类进行注释,而用 @Component 对那些比较中立的类进行注释
这里就是说把这个类交给Spring管理,重新起个名字叫userManager,由于不好说这个类属于哪个层面,就用@Component