当前位置: 代码迷 >> 综合 >> Maven管理的SpringBoot项目打成WAR包
  详细解决方案

Maven管理的SpringBoot项目打成WAR包

热度:29   发布时间:2024-01-24 15:50:41.0

修改pom文件

<groupId>com.test</groupId>
<artifactId>admin</artifactId>
<version>0.0.1-SNAPSHOT-test</version>
<packaging>war</packaging>

排除SpringBoot 默认Tomcat

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-tomcat</artifactId><scope>provided</scope>
</dependency>

 注册启动类

public class ServletInitializer extends SpringBootServletInitializer {@Overrideprotected SpringApplicationBuilder configure(SpringApplicationBuilder application) {return application.sources(Application.class);}
}

 执行打包命令:mvn clean package  -Dmaven.test.skip=true