SpringBoot项目打war包

1.pom文件打包方式修改为war

war

2.spring-boot-starter-tomcat的scope属性设置为provided


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

3.添加ServletInitializer类

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
 
public class ServletInitializer extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(PlatformApplication.class);
    }
}

注:PlatformApplication为SpringBoot的启动类

你可能感兴趣的:(SpringBoot项目打war包)