title: Deploying Spring Boot to Tomcat 10 produces 404 error
body: <p>I've followed about 15 different threads on Stack to try and resolve this, but I seem to be hitting a brick wall.</p>
  <p>I'm running JDK17 and Tomcat 10.0.22. I have followed a baeldung article for deploying a Spring Boot app on Tomcat, and I'm having no luck at all. I've tried used gradle and maven.</p>
  <p>With the provided block commented out, the war runs fine with java -jar spring-boot-deployment.war. However, when activating this line and dragging the war into the web app folder, it doesn't work.</p>
  <p>For example, just in spring boot localhost:8080/hello/ works fine
  after deploying to Tomcat and going to http://localhost:8080/spring-boot-deployment/hello/ I get <code>The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</code></p>
  <p>I'm not seeing any errors in the Tomcat logs, and the manager says its running. Given how many threads there are on this, it seems to be a pretty poorly documented/understood thing.</p>
  <pre class="lang-java prettyprint-override"><code>@SpringBootApplication
  public class SpringBootTomcatApplication extends SpringBootServletInitializer {
  
      public static void main(String[] args) {
          SpringApplication.run(SpringBootTomcatApplication.class, args);
      }
  }
  </code></pre>
  <pre class="lang-java prettyprint-override"><code>@RestController
  public class TomcatController {
  
      @GetMapping(value = &quot;/hello&quot;)
      public Collection&lt;String&gt; sayHello() {
          return IntStream.range(0, 10)
                  .mapToObj(i -&gt; &quot;Hello number &quot; + i)
                  .collect(Collectors.toList());
      }
  }
  </code></pre>
  <pre class="lang-xml prettyprint-override"><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 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;artifactId&gt;spring-boot-deployment&lt;/artifactId&gt;
      &lt;name&gt;spring-boot-deployment&lt;/name&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
      &lt;groupId&gt;com.baeldung.spring-boot-modules&lt;/groupId&gt;
      &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&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.6.7&lt;/version&gt;
          &lt;relativePath/&gt;
      &lt;/parent&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;/dependencies&gt;
  
      &lt;build&gt;
          &lt;finalName&gt;${artifactId}&lt;/finalName&gt;
          &lt;resources&gt;
              &lt;resource&gt;
                  &lt;directory&gt;src/main/resources&lt;/directory&gt;
                  &lt;filtering&gt;true&lt;/filtering&gt;
                  &lt;excludes&gt;
                      &lt;exclude&gt;**/conf.properties&lt;/exclude&gt;
                  &lt;/excludes&gt;
              &lt;/resource&gt;
          &lt;/resources&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;executions&gt;
                  &lt;execution&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;repackage&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;mainClass&gt;com.baeldung.springbootsimple.SpringBootTomcatApplication&lt;/mainClass&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>