springmvc+mybaits的系统架构:

springmvc和mybatis整合关键配置

第一步:整合dao层

         mybatis和spring整合,通过spring管理mapper接口。

         使用mapper的扫描器自动扫描mapper接口在spring中进行注册。

 

第二步:整合service层

         通过spring管理 service接口。

         使用配置方式将service接口配置在spring配置文件中。

         实现事务控制。

 

第三步:整合springmvc

         由于springmvc是spring的模块,不需要整合。


所需要的jar包:

数据库驱动包:mysql5.1

mybatis的jar包

mybatis和spring整合包

log4j包

dbcp数据库连接池包

spring3.2所有jar包

jstl包


mybatis配置文件     sqlMapConfig.xml:


db.properties

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/mybatis
jdbc.username=root
jdbc.password=



applicationContext-dao.xml


配置:
数据源
SqlSessionFactory
mapper扫描器


mybatis mapper接口映射文件 ItemsMapperCustom.xml


applicationContext-service.xml


 事务控制(applicationContext-transaction.xml)



springmvc.xml
创建springmvc.xml文件,配置处理器映射器、适配器、视图解析器


工程的web.xml





相关文章:

  • 2022-12-23
  • 2021-05-12
  • 2021-11-22
  • 2021-09-17
  • 2021-07-23
  • 2022-12-23
  • 2021-08-30
  • 2021-08-01
猜你喜欢
  • 2021-12-05
  • 2022-03-05
  • 2020-06-13
  • 2018-07-19
  • 2022-12-23
  • 2022-12-23
  • 2021-08-28
相关资源
相似解决方案