Spring笔记
Spring官网https://spring.io
框架图:
为什么要使用Spring
原先代码中存在的问题如下:
- 业务层:
public class BookServiceImpl implements BookService {
//业务层中使用new的方式创建的dao对象
private BookDao bookDao = new BookDaoImpl();
public void save() {
System.out.println("book service save ...");
bookDao.save();
}
}
- 数据层:
public class BookDaoImpl implements BookDao {
public void save() {
System.out.println("book dao save ...");
}
}
public class BookDaoImpl2 implements BookDao {
public void save() {
System.out.println("book dao save ...");
}
}