一、开发的环境
IDEA:idea 2022.2.3
构建工具:maven 3.8.6
服务器:tomcat 9
Spring版本:5.3.1
二、创建maven工程
1.添加web模块
a.在idea中点击打开设置
b.点击Projrect Structure,开始构建模块
c.点击加号,再点击New Module,新建一个模块
d.选择webapp,再点击create
e.点击OK,完成构建
2.引入依赖
a.在pom.xml中引入所需依赖
b.引入下列依赖
<dependencies>
<!-- SpringMVC -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.3.22</version>
</dependency>
<!--logback 日志 -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.9</version>
</dependency>
<!-- ServletAPI -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- Spring5和Thymeleaf整合包 -->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
<version>3.0.12.RELEA