1 回答

TA貢獻(xiàn)1946條經(jīng)驗(yàn) 獲得超4個(gè)贊
SSM現(xiàn)在是比較常用的框架有ssm,既是SpringMVC、Spring及MyBatis
1、確定需要集成版本,以mybatis-3.2.1、spring-framework-3.2.0.RELEASE為例
2、Spring3.2先和MyBatis3.2集成
3、創(chuàng)建web動(dòng)態(tài)工程:注意classpath路徑
4、添加Spring3.2+MyBatis3.2 mysql驅(qū)動(dòng)共計(jì)30個(gè)jar文件
18個(gè)spring相關(guān)的jar文件
MyBatis3.2 版本共9個(gè)jar文件
包含mysql驅(qū)動(dòng)共28個(gè)jar文件
jstl 2個(gè)jar 文件共計(jì)30個(gè)jar文件
jdbc.properties
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql:///ssm
jdbc.username=root
jdbc.password=admin
log4j.properties
5、寫配置文件的流程:
數(shù)據(jù)庫連接配置文件->DataSource->SqlSessionFactory->Mapper->Service->Controller
spring配置文件
UserMapper
也可以在接口里面定義主鍵的MyBatis映射
UserMapper.xml
UserServiceImpl
Spring3.2+SpringMVC3.2
spring配置文件
web.xml
UserController
webapp/WEB-INF/views/user.jsp
至此,集成完成,在此基礎(chǔ)上可再添加其他功能。每步都要截圖太麻煩了我就不上圖了。
- 1 回答
- 0 關(guān)注
- 780 瀏覽
添加回答
舉報(bào)