springboot怎么打成war包

1.添加spring-boot-starter-tomcat的依赖,scope provided
2.添加maven-war-plugin插件

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

    
        ${project.artifactId}
        
            
                org.apache.maven.plugins
                maven-war-plugin
                
                    false
                
            
        
    
  1. 修改打包方式为war : war
    3.spingboot Application类继承SpringBootServletInitializer 并覆盖configure方法
@SpringBootApplication
public class Demo extends SpringBootServletInitializer{
    public static void main(String[] args) {
        SpringApplication.run(Demo.class); 
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(Demo.class);
    }
}


你可能感兴趣的:(springboot怎么打成war包)