- 变量(filed) 注入
@Autowired
UserDao userDao;
- 构造器注入
final UserDao userDao;
@Autowired
public UserServiceImpl(UserDao userDao){
this.userDao = userDao;
}
- set 方法注入
private UserDao userDao;
@Autowired
public void setUserDao(UserDao userDao){
this.userDao = userDao;
}
- 这三种方式的区别