title: Spring-Boot MVC Template Not Loading (404 Not Found)
body: <p>I have an extremely simple Spring-Boot MVC application here that is not working. One Controller with one page not loading and receiving a 404 not found.</p>
  
  <p>I put a System.out.println("Home Page") statement in the controller method and validated that it is mapped and getting fired correctly but the template isn't loading.</p>
  
  <p>The error: </p>
  
  <pre><code>Whitelabel Error Page
  
  This application has no explicit mapping for /error, so you are seeing this as a fallback.
  
  Thu Nov 06 23:43:51 EST 2014
  There was an unexpected error (type=Not Found, status=404).
  </code></pre>
  
  <p>The folder structure:</p>
  
  <pre><code>src/main/java
   +-Application.java
   +-WebController.java
  
  src/main/resources
   +-templates
     +-index.html
  </code></pre>
  
  <p>Abbreviated console output:</p>
  
  <pre><code>Server initialized with port: 8080
  Starting service Tomcat
  Starting Servlet Engine: Apache Tomcat/7.0.55
  Initializing Spring embedded WebApplicationContext
  Root WebApplicationContext: initialization completed in 1947 ms
  Mapping servlet: 'dispatcherServlet' to [/]
  Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
  Mapped "{[/],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String app.WebController.index()
  Tomcat started on port(s): 8080/http
  Started Application in 5.552 seconds (JVM running for 6.366)
  Home Page
  Home Page
  Home Page
  </code></pre>
  
  <p>Configuration: </p>
  
  <pre><code>@EnableAutoConfiguration
  @Configuration
  @ComponentScan
  public class Application extends WebMvcConfigurerAdapter {
      public static void main(String[] args) {
           ConfigurableApplicationContext context = SpringApplication.run(Application.class);
      }
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>@Controller
  public class WebController {
      @RequestMapping(value="/")
      public String index(){
          System.out.println("Home Page");
          return "index";
      }
  }
  </code></pre>
  
  <p>index.html :</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;body&gt;
   &lt;h1&gt;Hello&lt;/h1&gt;    
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I have an extremely simple Spring-Boot MVC application here that is not working. One Controller with one page not loading and receiving a 404 not found.</p>
  
  <p>I put a System.out.println("Home Page") statement in the controller method and validated that it is mapped and getting fired correctly but the template isn't loading.</p>
  
  <p>The error: </p>
  
  <pre><code>Whitelabel Error Page
  
  This application has no explicit mapping for /error, so you are seeing this as a fallback.
  
  Thu Nov 06 23:43:51 EST 2014
  There was an unexpected error (type=Not Found, status=404).
  </code></pre>
  
  <p>The folder structure:</p>
  
  <pre><code>src/main/java
   +-Application.java
   +-WebController.java
  
  src/main/resources
   +-templates
     +-index.html
  </code></pre>
  
  <p>Abbreviated console output:</p>
  
  <pre><code>Server initialized with port: 8080
  Starting service Tomcat
  Starting Servlet Engine: Apache Tomcat/7.0.55
  Initializing Spring embedded WebApplicationContext
  Root WebApplicationContext: initialization completed in 1947 ms
  Mapping servlet: 'dispatcherServlet' to [/]
  Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
  Mapped "{[/],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String app.WebController.index()
  Tomcat started on port(s): 8080/http
  Started Application in 5.552 seconds (JVM running for 6.366)
  Home Page
  Home Page
  Home Page
  </code></pre>
  
  <p>Configuration: </p>
  
  <pre><code>@EnableAutoConfiguration
  @Configuration
  @ComponentScan
  public class Application extends WebMvcConfigurerAdapter {
      public static void main(String[] args) {
           ConfigurableApplicationContext context = SpringApplication.run(Application.class);
      }
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>@Controller
  public class WebController {
      @RequestMapping(value="/")
      public String index(){
          System.out.println("Home Page");
          return "index";
      }
  }
  </code></pre>
  
  <p>index.html :</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;body&gt;
   &lt;h1&gt;Hello&lt;/h1&gt;    
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>POM:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.App&lt;/groupId&gt;
      &lt;artifactId&gt;App&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  
      &lt;name&gt;App&lt;/name&gt;
      &lt;description&gt;App&lt;/description&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.1.8.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&lt;/artifactId&gt;
          &lt;/dependency&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-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.h2database&lt;/groupId&gt;
              &lt;artifactId&gt;h2&lt;/artifactId&gt;
              &lt;version&gt;1.4.181&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!--dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-redis&lt;/artifactId&gt;
          &lt;/dependency--&gt; 
          &lt;dependency&gt;
              &lt;groupId&gt;com.firebase&lt;/groupId&gt;
              &lt;artifactId&gt;firebase-client&lt;/artifactId&gt;
              &lt;version&gt;1.0.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.scala-lang&lt;/groupId&gt;
              &lt;artifactId&gt;scala-library&lt;/artifactId&gt;
              &lt;version&gt;2.10.4&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;start-class&gt;App.Application&lt;/start-class&gt;
          &lt;java.version&gt;1.7&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;repositories&gt;
          &lt;repository&gt;
              &lt;id&gt;spring-releases&lt;/id&gt;
              &lt;name&gt;Spring Releases&lt;/name&gt;
              &lt;url&gt;http://repo.spring.io/libs-release&lt;/url&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
  
      &lt;pluginRepositories&gt;
          &lt;pluginRepository&gt;
              &lt;id&gt;spring-releases&lt;/id&gt;
              &lt;name&gt;Spring Releases&lt;/name&gt;
              &lt;url&gt;http://repo.spring.io/libs-release&lt;/url&gt;
          &lt;/pluginRepository&gt;
      &lt;/pluginRepositories&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>