1.pom文件打包方式修改为war
<packaging>war</packaging>
2.spring-boot-starter-tomcat的scope属性设置为provided
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
3.添加ServletInitializer类
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(PlatformApplication.class);
}
}
注:PlatformApplication为SpringBoot的启动类