springboot 外置tomcat

1.移除嵌入式tomcat插件

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

2.添加servlet依赖

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

3.修改plugin

        
            

            
                org.apache.maven.plugins
                maven-war-plugin
                
                    false
                
            
        

4.继承SpringBootServletInitializer,重写configure

@SpringBootApplication
public class BallApplication extends SpringBootServletInitializer {

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

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        // 注意这里要指向原先用main方法执行的Application启动类
        return builder.sources(BallApplication.class);
    }

}

你可能感兴趣的:(springboot 外置tomcat)