1.添加spring-boot-starter-tomcat的依赖,scope provided
2.添加maven-war-plugin插件
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
- 修改打包方式为war : <packaging>war</packaging>
3.spingboot Application类继承SpringBootServletInitializer 并覆盖configure方法
@SpringBootApplication
public class Demo extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(Demo.class);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Demo.class);
}
}
网友评论