黑马程序员技术交流社区
标题:
【成都校区JavaEE24期】
[打印本页]
作者:
yshshe1700
时间:
2019-5-31 14:04
标题:
【成都校区JavaEE24期】
Web层
public class test01 {
public static void main(String[] args) {
ApplicationContext app =
new ClassPathXmlApplicationContext("applicationContext.xml");
// UserDao userDao = (UserDao) applicationContext.getBean("userDao");
// userDao.save();
UserService userService = (UserService) app.getBean("userService");
userService.serv();
}
}
Service层
@Component("userService")
public class UserServiceImpl implements UserService {
@Autowired
@Qualifier("userDao")
private UserDao userDao;
public void setUserDao(UserDao userDao) {
this.userDao = userDao;
}
public void serv() {
userDao.save();
}
}
Daon层
@Component("userDao")
public class UserDaoImpl implements UserDao {
public void save() {
System.out.println("你好世界");
}
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2