依赖注入(Dependency Injection)----DI

Constructor-based Dependency Injection(基于构造器的依赖注入)

public class UserServiceImpl implements UserService {
    private UserDao userDao;

    public void setUserDao(UserDao userdao) {
        this.userDao=userdao;
    }
    public void getUser() {
        userDao.getUser();
    }
}

 

上一篇:python 特效之一行代码能做哪些丧心病狂的事情


下一篇:Juc11_Java内存模型之JMM、八大原子操作、三大特性、读写过程、happens-before(一)