After the springboot project is packaged into war, tomcat is deployed, and when the service is called, a 404 error is displayed
Open swagger-ui.html, only swagger-ui header is displayed, not the interface list.
Check the tomcat log and found that springboot has not started.
After investigation, it was found that the SpringBootStartApplication class was not added
New SpringBootStartApplication class
public class SpringBootStartApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
// 注意这里要指向原先用main方法执行的Application启动类
return builder.sources(DemoApplication.class);
}
}
problem solved!
Note: When packaging war, springboot and DemoApplication must be started through SpringBootStartApplication (jar is not needed)