title: How to run Springboot app on Tomcat server?
body: <p>I am trying to run Springboot app on Tomcat server, however all of my experiments failed.</p>
  <p>Here you can see the <code>pom.xml</code>:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
      xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.5.0&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      &lt;groupId&gt;com.example&lt;/groupId&gt;
      &lt;artifactId&gt;SpringbootTomcat&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;name&gt;SpringbootTomcat&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot with Tomcat&lt;/description&gt;
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
          &lt;start-class&gt;com.example.SpringbootTomcat.SpringbootTomcatApplication&lt;/start-class&gt;
      &lt;/properties&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  <p>the main class:</p>
  <pre><code>package com.example.SpringbootTomcat;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RestController;
  
  @SpringBootApplication
  @RestController
  public class SpringbootTomcatApplication {
  
  //  @GetMapping(&quot;/test&quot;)
      @RequestMapping(value = &quot;/test&quot;)
      public String test(){
          return &quot;Application deployed!&quot;;
      }
  
      public static void main(String[] args) {
          SpringApplication.run(SpringbootTomcatApplication.class, args);
      }
  
  }
  </code></pre>
  <p>ServletInitializer is in an other class:</p>
  <pre><code>package com.example.SpringbootTomcat;
  
  import org.springframework.boot.builder.SpringApplicationBuilder;
  import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
  
  public class ServletInitializer extends SpringBootServletInitializer {
  
      @Override
      protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
          return application.sources(SpringbootTomcatApplication.class);
      }
  
  }
  </code></pre>
  <p>It is generated this way from <a href="https://start.spring.io/" rel="nofollow noreferrer">https://start.spring.io/</a>.</p>
  <p>Tomcat is running on localhost:1234.</p>
  <p>I copied the war file into <code>webapps</code> folder. However, when I type in browser <code>http://localhost:1234/SpringbootTomcat-0.0.1-SNAPSHOT/test</code>, I get the following message:</p>
  <pre><code>HTTP Status 404 – Not Found
  Type Status Report
  
  Message The requested resource [/SpringbootTomcat-0.0.1-SNAPSHOT/test] is not available
  
  Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
  
  </code></pre>
  <p>I am running Tomcat 10.0.6 on my computer, <code>CATALINA_HOME</code> is set to folder of Tomcat, <code>CLASSPATH</code> is <code>CATALINA_HOME\lib</code>.</p>
  <p>It only works as a Maven app but not as Tomcat application.</p>
  <p>How can I run then the application on Tomcat Server?</p>