标签:打包 spring follow extends art turn lock ota servlet
1、在pom.xml文件中修改<packaging>war</packaging>
2、移除springboot自带的tomcat
<!--移除自带的tomcat-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
3、在启动类上继承SpringBootServletInitializer
添加以下内容
@SpringBootApplicationbr/>@EnableScheduling
public class JavaSayApplication extends SpringBootServletInitializer {public static void main(String[] args) {
SpringApplication.run(JavaSayApplication.class, args);
}/将springboot项目打包成war/
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
// 注意这里要指向原先用main方法执行的Application启动类
return builder.sources(JavaSayApplication.class);
}}
4.
maven clean
maven package
标签:打包 spring follow extends art turn lock ota servlet
原文地址:https://blog.51cto.com/14802795/2495980