整合spring+springmvc+mybatis
开发前准备:
spring 框架的jar包,在这里使用的是spring-5.0.4 PS:spring中包含了springmvc

spring-aop依赖的jar包

mybatis的jar包

mybatis-spring的整合包

mysql-jdbc的jar包

阿里巴巴的druid数据库连接池

日志jar包,注意是log4j 1.2.17

进行ssm整合配置:
定义好目录:

配置db.properties

配置log4j.properties

mybatis-config.xml配置文件:

spring整合mybatis的配置文件:applicationContext-dao.xml

上面的配置中值得注意的是:

如果不想将mapper文件和mapper接口放在一起,那么我们就必须指定mapper文件的位置:

通过注解的方式将所有的service放入spring Ioc 容器中:applicationContext-service.xml

配置spring的事务: applicationContext-tx.xml

springmvc的配置文件:springmvc.xml

web.xml的配置文件:



浙公网安备 33010602011771号