Spring Boot War deployed to Tomcat


I am trying to deploy a Spring Boot app to Tomcat, because I want to deploy to AWS.
I created a WAR file, but it does not seem to run on Tomcat, even though it is visible.

0. Here is my app:

public class App {
    public static void main(String[] args) {
        SpringApplication.run(SampleController.class, args);

public class SampleController {
    String home() {
        String input = "Hi! Please use 'tag','check' and 'close' resources.";
        return input;

application.properties has following:

  1. After reading a number of pages and question-answers I added following to my POM:



  2. I ran"mvn package"and got WAR file (size 250Mb), which I put into "webapps" folder.

  3. I started Tomcat and am able to see my app listed, in my case "/highlighter-1.0-SNAPSHOT".
  4. Clicking on the link for the app results in "Status 404" page.
  5. When I run Spring Boot app just by itself, without container it runs on localhost:7777, but there is nothing there when I run it in Tomcat.

There is another reference. Not sure how useful it is.

Best Answer

This guide explains in detail how to deploy Spring Boot app on Tomcat:

Essentially I needed to add following class:

public class WebInitializer extends SpringBootServletInitializer {   
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(App.class);

Also I added following property to POM: