1.使用ideal 构建并初始化spring boot项目时,应注意避免重复添加 **spring-boot-starter-tomcat **依赖
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
2.打包方式为“war”包时;
1)pom文件中得先声明打包方式为war;
<packaging>war</packaging>
2)打包时,要将spring-boot-starter-tomcat的<scope>设置为provided,即不使用spring-boot内嵌tomcat;
<!--打包时,请释放注释provided-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>