title: Can't serve dynamic Web Content with Spring Boot and Kotlin
body: <p>Based on a Spring Boot <a href="https://spring.io/guides/gs/serving-web-content/" rel="nofollow noreferrer">tutorial</a> to served dynamic web content, I wanted to do the same in Kotlin. My Kotlin project is based on this <a href="https://spring.io/blog/2016/02/15/developing-spring-boot-applications-with-kotlin" rel="nofollow noreferrer">tutorial</a>. I've no issue running the code of both tutorials. </p>
  
  <p>From my understanding, I only needed to add a controller that would return a reference to a template. </p>
  
  <p>Here <code>HelloController.kt</code> (located under src/main/kotlin/foo/controller) :</p>
  
  <pre><code>package foo.controller
  
  import org.slf4j.LoggerFactory
  import org.springframework.stereotype.Controller
  import org.springframework.web.bind.annotation.RequestMapping
  
  @Controller
  class HelloController {
  
      private val log = LoggerFactory.getLogger(HelloController::class.java)
  
      @RequestMapping("/")
      fun hello(): String {
          log.info("foo")
          return "index"
      }
  }
  </code></pre>
  
  <p>Here is the simple "template", <code>index.html</code> that I want to access (located under  src/main/resources/templates/index.html):</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
  Bar
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>So technically, if I go to <code>localhost:8080</code> I should have <code>index.html</code> displayed which I don't. Instead I have a 404 error. I do have the logged displayed so the <code>hello</code>method is called. What am I doing wrong? I didn't see any configuration file in the Spring Boot tutorial so I guess Spring is doing something under the hood to get the correct ressource from what a function returns. </p>
  
  <p>EDIT: </p>
  
  <p>Has requested my graddle imports:</p>
  
  <pre><code>buildscript {
      val springBootVersion = "1.4.3.RELEASE"
      val kotlinVersion = "1.0.6"
      extra["kotlinVersion"] = kotlinVersion
  
      repositories {
          mavenCentral()
      }
  
      dependencies {
          classpath("org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion")
          classpath("org.jetbrains.kotlin:kotlin-noarg:$kotlinVersion")
          classpath("org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion")
          classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
      }
  }
  
  apply {
      plugin("kotlin")
      plugin("kotlin-spring")
      plugin("kotlin-jpa")
      plugin("org.springframework.boot")
  }
  
  version = "0.0.1-SNAPSHOT"
  
  configure&lt;JavaPluginConvention&gt; {
      setSourceCompatibility(1.8)
      setTargetCompatibility(1.8)
  }
  
  repositories {
      mavenCentral()
  }
  
  val kotlinVersion = extra["kotlinVersion"] as String
  
  dependencies {
      compile("org.springframework.boot:spring-boot-starter-web")
      compile("org.springframework.boot:spring-boot-starter-data-jpa")
      compile("com.h2database:h2")
      compile("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
      compile("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
      compile("org.apache.commons:commons-io:1.3.2")
      compile("org.apache.commons:commons-lang3:3.3.1")
      testCompile("org.springframework.boot:spring-boot-starter-test")
  }
  </code></pre>