title: Spring boot war cannot find index.html
body: <p>Im a beginner in Spring boot and tomcat, and i get this issue:</p>
  
  <p>When deploying a spring boot war file on a the tomcat server, i get a problem when i want to add a static index.html alongside with it as a war.</p>
  
  <p>to enable it to be deployed as war i added this to my application class:</p>
  
  <pre><code>@SpringBootApplication
  @ComponentScan(basePackages = {"com.app"})
  @EnableMongoRepositories(basePackages = {"com.app"})
  public class MyApp extends SpringBootServletInitializer {
  
      @Override
      protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
          return application.sources(MyApp.class);
      }
  
      public static void main(String[] args) {
          SpringApplication.run(MyApp.class, args);
      }
  }
  </code></pre>
  
  <p>now the application works, but the index.html (which is located under src/main/resources) won't show (im getting Whitelabel Error Page with "There was an unexpected error (type=Method Not Allowed, status=405).
  Request method 'GET' not supported")</p>
  
  <p>but if i create it like this:</p>
  
  <pre><code>@SpringBootApplication
  @ComponentScan(basePackages = {"com.app"})
  @EnableMongoRepositories(basePackages = {"com.app"})
  public class MyApp {
  
      public static void main(String[] args) {
          SpringApplication.run(MyApp.class, args);
      }
  }
  </code></pre>
  
  <p>it shows me the index.html (but the application won't work for a GET request from the browser which work earlier i get HTTP Status 404 - The requested resource is not available. ).</p>
  
  <p>How can i configure it so they both will work?</p>
  
  <p>this is my pom.xml</p>
  
  <pre><code>&lt;packaging&gt;war&lt;/packaging&gt;
  &lt;build&gt;
      &lt;finalName&gt;myapp&lt;/finalName&gt;
  &lt;/build&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;1.3.1.RELEASE&lt;/version&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&lt;/groupId&gt;
          &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-mongodb&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
          &lt;artifactId&gt;spring-data-mongodb&lt;/artifactId&gt;
          &lt;version&gt;1.8.1.RELEASE&lt;/version&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;!-- Test --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;4.12&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.jayway.restassured&lt;/groupId&gt;
          &lt;artifactId&gt;rest-assured&lt;/artifactId&gt;
          &lt;version&gt;2.7.0&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  </code></pre>