springboot 打war包

使用版本:

springboot 2.0.0

jdk 8

tomcat 8.50以上

低版本的tomcat可能会报错

Invalid byte tag in constant pool : 19


修改pom.xml

war


            org.springframework.boot

            spring-boot-starter-web

           

               

                    org.springframework.boot

                    spring-boot-starter-tomcat

               

           

       


去掉starter中内嵌的tomcat引用

增加plugin war

        

            

                maven-war-plugin

                

                    ${project.name}

                    false

                

            

            

                org.springframework.boot

                spring-boot-maven-plugin

                ${spring-boot.version}

                

                    

                        

                            repackage

                        

                    

                

            

            

    


修改代码


application.source的入参为入口类WebApplication

@ServletComponentScan

public class ServletInitializer extends SpringBootServletInitializer {


    @Override

    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {

        logger.info("开始启动项目。。。ServletInitializer");

        return application.sources(WebApplication.class);

    }


}

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