springboot项目打包成war包

2021-01-19 10:14

阅读:469

标签:pid   info   prot   app   执行   ati   文件中   tin   ica   

1、在pom.xml文件中修改

war

2、移除springboot自带的tomcat


org.springframework.boot
spring-boot-starter-tomcat
provided

3、在启动类上继承SpringBootServletInitializer

添加以下内容

@SpringBootApplication@EnableScheduling
br/>@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

技术图片

springboot项目打包成war包

标签:pid   info   prot   app   执行   ati   文件中   tin   ica   

原文地址:https://blog.51cto.com/14802795/2495979


评论


亲,登录后才可以留言!