前面的框架一步一步学过来,知识点很多很杂,就像学游泳,一开始总是要记着许多分解动作,抬手、弯臂、划水等等,到后来的能入水就能下意识的游还有很多的代码量,所幸还在学习的路上,路漫漫。
小项目源代码:source code
1、SpringMVC整合Mybatis:
整合步骤:
Dao层:
- SqlMapConfig.xml,空文件即可,需要文件头。
- applicationContext-Dao.xml
- 数据库连接池datasource
- SqlSessionFactory对象
- 配置mapper文件扫描器(如果是单表,mapper和pojo可由Mybatis逆向工程自动创建
service层:
-
applicationContext-service.xml: @service包扫描器,使得service包里面的类可以使用注解获得
-
applicationContext-trans.xml:配置事务
Controller层:
- Springmvc.xml
- @controller包扫描器<