springboot打成war包四步

总共四步,POM文件里面三步

1、

war

2.排除内置tomcat

        
            org.springframework.boot
            spring-boot-starter-web
            2.1.5.RELEASE
            
                
                    spring-boot-starter-tomcat
                    org.springframework.boot
                
            

        

3.增加一些serverlet依赖

 
            javax.servlet
            javax.servlet-api
            4.0.1
            provided
        

四、启动类的时候,引导指向springboot的启动类


@SpringBootApplication
public class ProxyApplication  extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {

        return application.sources(ProxyApplication.class);

    }

    public static void main(String[] args) {
        SpringApplication.run(ProxyApplication.class,args);

    }
}

 

如果出现报错信息:

报错信息:

Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml 

加下面这一段

            
                maven-war-plugin
                2.6
                
                    
                    false
                
            

 

你可能感兴趣的:(spring,boot)