springboot war部署
将打包方式设置为war(pom.xml文件)
<packaging>war</packaging>
移除tomcat
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- 移除嵌入式tomcat插件 -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--HttpServletRequest所需-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
改写启动类
继承SpringBootServletInitializer
@SpringBootApplication
//public class BlogsApplication {
public class BlogsApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(BlogsApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(BlogsApplication.class, args);
}
}