Spring Boot application gives 404 when deployed to Tomcat but works with embedded server
I had forgotten to tweak my Application.java
file to extend SpringBootServletInitializer
and override the configure
method.
Corrected file:
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Application.class);
}
}
Hat tip to https://mtdevuk.com/2015/07/16/how-to-make-a-spring-boot-jar-into-a-war-to-deploy-on-tomcat/ for pointing out my mistake.
More info at Create a deployable war file in Spring Boot Official docs.