学习笔记——SSM整合(思路、步骤)
2023-01-22
一、SSM整合
1、Spring + SpringMVC
(1)容器管理对象,由DispatcherServlet管理
(2)Spring容器对象,由ContextLoaderListener管理
2、解决组件扫描的冲突问题
(1)SpringMVC只扫描Controller层
(2)Spring扫描排除Controller层
2、Spring+Mybatis
(1)关于数据源、事务管理的代码冲突问题
同意交给Spring管理
(2)Spring管理Mybatis核心对象
①SqlSessionFactory
②Mapper代理对象
二、SSM整合步骤
1、Spring + SpringMVC
(1)导入jar包
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.3.1</version> </dependency> <!-- https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf-spring5 --> <dependency> <groupId>org.thymeleaf</groupId> <artifactId>thymeleaf-spring5</artifactId> <version>3.0.12.RELEASE</version> </dependency> <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>4.0.1</version> <scope>provided</scope> </dependency>