书单推荐:成为Java顶级程序员架构师 ,这20来本(高薪)必看点击获取
1.指定war打包方式
<packaging>jar</packaging>
2.pom.xml添加spring-boot-maven-plugin插件
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.0.1.RELEASE</version> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
3.pom.xml添加spring-boot-starter-tomcat依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency>
4.启动类继承SpringBootServletInitializer并重写configure方法
@SpringBootApplication public class Application extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(Application.class); } public static void main(String[] args) throws Exception { SpringApplication.run(Application.class, args); } }
转载请注明:谷谷点程序 » 解决Spring Boot+maven打war包常见错误