SSM框架整合
- IDEA整合SSM框架
-
- 开发环境
- idea新建maven项目
- 配置依赖,pom.xml
- web.xml中配置Spring、SpringMVC、字符编码过滤器、加载静态资源
- jdbc.properties 配置数据库相关属性
- 在 spring.xml 中配置 Spring 和 Mybatis 的整合
- config.xml 中配置一些 MyBatis 辅助信息,比如打印 SQL 等。
- 配置 springmvc.xml
- 实体类Book
- BookRepository
- BookRepository.xml
- BookService
- BookServiceimpl
- BookHandler
- 此时SSM框架就整合完成了,我的目录结构如下:
IDEA整合SSM框架
今天自己手动搭建一下SSM框架,重温一下自己之前实习的项目。
开发环境
IEDA 2020.3
Tomcat 10.0.5
Maven 3.6.3
Mysql 8.0.23
idea新建maven项目
配置依赖,pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.dasheng</groupId>
<artifactId>ssmbuild</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>ssmbuild Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!--SpringMVC-->
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.2.11.RELEASE</version>
</dependency>
<!--Spring JDBC-->
<!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.2.12.RELEASE</version>
</dependency>
<!--Spring AOP-->
<!-- https://mvnrepository.com/artifact/org.springframework/spring-aop -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>5.2.12.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-aspects -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>5.2.14.RELEASE</version>
</dependency>
<!--MyBatis-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.5</version>
</dependency>
<!--Spring 整合 MyBatis-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.2</version>
</dependency>
<!--MySQL驱动-->
<dependency>
<groupId>mysql</groupId>