pom配置
1.配置打包方式
2.移除springboot自带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>
3.项目如有servlet相关报错引入servlet
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
4.maven plugin设置
<finalName>xxxxx</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
5.springboot启动类修改
public class StartApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(StartApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(StartApplication.class);
}
}
6.命令窗口输入命令打包(打包前最好先编译整个项目)
mvn clean package