title: Can't access REST Controller with Spring Boot autoconfiguration
body: <p>I am trying to create a simple REST service with Spring Boot following <a href="http://spring.io/guides/tutorials/bookmarks/" rel="nofollow noreferrer">this tutorial</a>. The "Hello World" html file from the webapp folder (<code>index.html</code>) is opening on <code>http://localhost:8080/my-rest-app/</code> (I created a Maven-Web-App because I want to have a "Welcome Page" for the Service). But if I try to access the REST service on <code>http://localhost:8080/my-rest-app/user</code> I get a 404 message.</p>
  
  <p>pom.xml:</p>
  
  <pre class="lang-xml prettyprint-override"><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;service&lt;/groupId&gt;
      &lt;artifactId&gt;my-rest-app&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
  
      &lt;name&gt;my-rest-app&lt;/name&gt;
  
      &lt;properties&gt;
          &lt;endorsed.dir&gt;${project.build.directory}/endorsed&lt;/endorsed.dir&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;/properties&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.4.1.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&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;/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>Application.java: </p>
  
  <pre><code>package service.my.rest.app;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  @SpringBootApplication
  //@ComponentScan({"service.my.rest.app", "service.my.rest.app.controller"})
  //@ComponentScan(basePackageClasses = UserController.class)
  public class Application {
  
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  
  }
  </code></pre>
  
  <p>UserController.java:</p>
  
  <pre><code>package service.my.rest.app.controller;
  
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RestController;
  
  @RestController
  @RequestMapping("/user")
  public class UserController {
  
      @RequestMapping(method = RequestMethod.GET)
      public String getUser() {
          return "Hello";
      }
  
  }
  </code></pre>
  
  <p>What am I missing? Is the URL to the service wrong? I read somewhere that the context path of the Spring Boot REST service is always <code>/</code>, that would meant that I have to access the service over <code>http://localhost:8080/my-rest-app/</code> but this does not working ether (without <code>index.html</code>). Changing the context path in the <code>application.properties</code> with <code>server.contextPath=/my-rest-app</code> and <code>server.port=8080</code> also didn't help.</p>