springboot项目如何打war包,并发布到外部tomcat部署

1、修改pom        <packaging>war</packaging> 

2、移除spring-boot-starter-web依赖中的tomcat依赖

  

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <!‐‐编译时依赖,但不会打包进去‐‐> 
            <scope>provided</scope>
        </dependency>    

 3、主启动类上实现SpringBootServletInitializer 重写confiure方法 

  

@SpringBootApplication 
public class DemoMain extends SpringBootServletInitializer {
    public static void main(String[] args){
        SpringApplication.run(DemoMain.class,args);
    }
            @Override
            protected SpringApplicationBuilder configure(SpringApplicationBuilder builder){
          return builder.sources(DemoMain.class);
    }  
}
        

  

posted @ 2020-06-27 19:53  wl_王麟  阅读(246)  评论(0编辑  收藏  举报