title: 404 error on main controller when using spring boot
body: <p>I m trying to do Spring MVC tutorial:</p>
  
  <p>It makes you create a main controller ad start a SpringApplication.</p>
  
  <p>When I run the SpringApplication, I can see that a Tomcat server gets started, a controller class gets instanced as it should.
  However, the mapping seems to fail : @RequestMapping("/greeting")
  When I try to browse <a href="http://localhost:8080/TestSpringOpenEMM2/greeting" rel="noreferrer">http://localhost:8080/TestSpringOpenEMM2/greeting</a>
  or <a href="http://localhost:8080/TestSpringOpenEMM2/greeting" rel="noreferrer">http://localhost:8080/TestSpringOpenEMM2/greeting</a> , I always get a 404 error.
  (TestSpringOpenEMM2 is my project name).</p>
  
  <p>I use eclipse IDE.</p>
  
  <p>Here are my files:</p>
  
  <pre><code>package application;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  
  @SpringBootApplication
  public class Application {
  
      public static void main(String[] args) {
  
          System.out.println("App starting" );
          SpringApplication.run(Application.class, args);
          System.out.println("App started" );
      }
  }
  </code></pre>
  
  <p>controller:</p>
  
  <pre><code>import javax.servlet.annotation.WebServlet;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestParam;
  
  
  @Controller
  public class GreetingController {
  
  
  
  static{
      System.out.println("Static init GreetingController");
  
  
  
  }
  
  
  
  
      @RequestMapping("/greeting")
      public String greeting(@RequestParam(value="name", required=false, defaultValue="World") String name, Model model) {
          System.out.println("starting servlet (greeting)");
  
          model.addAttribute("name", name);
          return "greeting";
      }
  
      public GreetingController(){
          super();
  
          System.out.println("new GreetingController");
  }
  }
  </code></pre>
  
  <p>pom:</p>
  
  <pre><code>&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;TestSpringOpenEMM2&lt;/groupId&gt;
    &lt;artifactId&gt;TestSpringOpenEMM2&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;war&lt;/packaging&gt;
    &lt;build&gt;
      &lt;sourceDirectory&gt;src&lt;/sourceDirectory&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.6&lt;/version&gt;
          &lt;configuration&gt;
            &lt;warSourceDirectory&gt;WebContent&lt;/warSourceDirectory&gt;
            &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;version&gt;3.3&lt;/version&gt;
          &lt;configuration&gt;
            &lt;source&gt;1.7&lt;/source&gt;
            &lt;target&gt;1.7&lt;/target&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
    &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot&lt;/artifactId&gt;
          &lt;version&gt;1.2.5.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-autoconfigure&lt;/artifactId&gt;
          &lt;version&gt;1.2.5.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
          &lt;version&gt;4.1.7.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
          &lt;artifactId&gt;tomcat-embed-logging-juli&lt;/artifactId&gt;
          &lt;version&gt;8.0.23&lt;/version&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>