需要在springBoot启动类也就是SpringBootApplication的同级目录创建一个新的类,具体可以参考如下
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
/**
* 部署war包支持
*/
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder applicationBuilder) {
return applicationBuilder.sources(SpringbootApplicationStarter.class);
}
}
注意是同级目录下