1、去除springboot内置tomcat
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-tomcat</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- provided:打包时不会带上tomcat -->
<dependency>
<artifactId>spring-boot-starter-tomcat</artifactId>
<groupId>org.springframework.boot</groupId>
<scope>provided</scope>
</dependency>
2、打开tomcat配置文件server.xml,修改Host中的appBase,将其变为空
<Host name=“localhost” appBase="" unpackWARs=“true” autoDeploy=“true”>
重启tomcat即可