spring boot war包形式部署

步骤一:在pom中修改packaging值

war

步骤二:在pom中将spring-boot-starter-web模块移除tomcat插件


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

步骤三:添加一个类继承SpringBootServletInitializer并重写configure方法

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;

/**
 * Created by Administrator on 2018/9/1.
 */
public class WebApplication extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(SpringbootApplication.class);
    }
}

你可能感兴趣的:(spring boot war包形式部署)