If the package is deployed to the war outside of tomcat, the need to increase SpringBootServletInitializer subclass, and override its configure method, or class where the main function inherit SpringBootServletInitializer subclass, and override the configure method.
@SpringBootApplication //继承SpringBootServletInitializer子类 public class Demo2Application extends SpringBootServletInitializer { //重写configure方法 @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(Demo2Application.class); } public static void main(String[] args) { SpringApplication.run(Demo2Application.class, args); } }