SpringBoot 项目打包成war包,部署到Tomcat
SpringBoot 项目打包成war包,部署到Tomcat。
-
先有maven 插件
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
-
在pom.xml中将打包形式 jar 修改为war
<packaging>war</packaging>
-
构建项目名称
<finalName>xdclass_springboot</finalName>
-
修改启动类,继承 SpringBootServletInitializer
public class XdclassApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(XdclassApplication.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(XdclassApplication.class, args);
}
}
-
解压到 tomcat, 启动tomcat。