title: Spring Boot 404 when trying to load a HTML file using Thymeleaf
body: <p>Like the title says, I'm getting the Whitelabel 404 error page when trying to access localhost:8080. </p>
  
  <p><strong>Main class</strong>:</p>
  
  <pre><code>package com.michaelLong.studentaddressbook;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
  
  @SpringBootApplication
  public class StudentAddressBookApplication extends SpringBootServletInitializer {
  
      public static void main(String[] args) {
  
          SpringApplication.run(StudentAddressBookApplication.class, args);
      }
  }
  </code></pre>
  
  <p><strong>pom.xml</strong>: </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.michaelLong&lt;/groupId&gt;
      &lt;artifactId&gt;student-address-book&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
  
      &lt;name&gt;student-address-book&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&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;2.0.5.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&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;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-thymeleaf&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-devtools&lt;/artifactId&gt;
              &lt;scope&gt;runtime&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;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;jstl&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
              &lt;artifactId&gt;tomcat-embed-jasper&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-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&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><strong>Controller</strong>:</p>
  
  <pre><code>package controller;
  
  import model.Student;
  import model.StudentRepository;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.*;
  import org.springframework.ui.Model;
  import java.util.Map;
  
  @Controller
  public class StudentController {
  
      @Autowired
      StudentRepository studentRepository;
  
      @GetMapping("/")
      public String showStudents(Model model){
          model.addAttribute("students", studentRepository.findAll());
          return "showStudents";
      }
  }
  </code></pre>
  
  <p><strong>application.properties</strong>:</p>
  
  <pre><code>spring.jpa.hibernate.ddl-auto=none
  spring.datasource.url=jdbc:mysql://localhost:3306/StudentAddressBook
  spring.datasource.username=root
  spring.datasource.password=SQLpassword
  </code></pre>
  
  <p><strong>showStudents.html</strong>:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns:th="http://www.thymeleaf.org"&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;Student List&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h2&gt;List of students&lt;/h2&gt;
  
  &lt;table&gt;
      &lt;tr&gt;
          &lt;th&gt;Id&lt;/th&gt;
          &lt;th&gt;First name&lt;/th&gt;
          &lt;th&gt;Last name&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr th:each="student: ${students}"&gt;
          &lt;td th:text="${student.id}"&gt;Id&lt;/td&gt;
          &lt;td th:text="${student.firstName}"&gt;First name&lt;/td&gt;
          &lt;td th:text="${student.lastName}"&gt;Last name&lt;/td&gt;
      &lt;/tr&gt;
  
  &lt;/table&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Project structure</strong>: </p>
  
  <pre><code>src
  |__main
     |__java
     |  |__com.example.studentaddressbook
     |  |  |__StudentAddressBookApplication
     |  |__controller
     |  |  |__StudentController
     |  |__model
     |     |__Student
     |     |__StudentRepository
     |__resources
        |__static
        |__templates
        |  |__showStudents.html
        |__application.properties
  </code></pre>
  
  <p>I've tried looking at a lot of different tutorials, and a few SO posts like these: 
  <a href="https://stackoverflow.com/questions/42028909/spring-boot-and-thymeleaf-cant-find-html-templates">Spring Boot and Thymeleaf: Can&#39;t find HTML templates</a> &amp; <a href="https://stackoverflow.com/questions/40795952/why-the-html-page-doesnt-get-showed-in-thymeleaf">Why the html page doesn&#39;t get showed in thymeleaf?</a></p>
  
  <p>I was originally trying to use JSPs, but I couldn't get those to work either. I feel like I'm banging my head against the wall at this point and I'm not sure what else to do. This is my first time trying to use Spring Boot and Thymeleaf, so I'm having some difficulty figuring this out.</p>
  
  <p>Any help trying to figure out why I can't access the HTML page would be greatly appreciated.</p>