title: RequestMapping of SpringBoot Not working
body: <p>I am learning Spring Boot for building Applications. I am trying to build my first Spring Boot Application with a controller in different package as application. Tomcat instance comes up but request does not reach RestController registered for the URI.</p>
  
  <p>Following is the controller class:</p>
  
  <pre><code>package com.spring.controllers;
  
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RestController;
  
  @RestController
  public class HelloController {
  
      @RequestMapping(value = "/abc")
      public String getHi() {
          System.out.println("End Point hit");
          return "Hi";
      }
  }
  </code></pre>
  
  <p>Following is the application class:</p>
  
  <pre><code>package com.spring.boot;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  @SpringBootApplication(scanBasePackages = {"com.spring.controllers"})
  public class SpringBootMain {
  
      public static void main(String args[]) {
          SpringApplication.run(SpringBootMain.class, args);
      }
  }
  </code></pre>
  
  <p>Pom.xml</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;RandomProjects&lt;/groupId&gt;
  &lt;artifactId&gt;SpringBoot&lt;/artifactId&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  
  &lt;properties&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.3.2&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.8&lt;/source&gt;
                  &lt;target&gt;1.8&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
              &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;1.6.0&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;mainClass&gt;com.spring.boot.SpringBootMain&lt;/mainClass&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  
  &lt;dependencies&gt;
  
      &lt;!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.5.6.RELEASE&lt;/version&gt;
          &lt;type&gt;pom&lt;/type&gt;
      &lt;/dependency&gt;
  
  
  
      &lt;!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;version&gt;1.5.6.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  
  
  &lt;/dependencies&gt;
  </code></pre>
  
  <p></p>
  
  <p>Logs when tomcat starts:</p>
  
  <pre><code>  .   ____          _            __ _ _
   /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
  ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
   \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
    '  |____| .__|_| |_|_| |_\__, | / / / /
   =========|_|==============|___/=/_/_/_/
   :: Spring Boot ::        (v1.5.6.RELEASE)
  
  2017-12-25 16:41:16.236  INFO 50314 --- [BootMain.main()] com.spring.boot.SpringBootMain           : Starting SpringBootMain on f45c89be9049.ant.amazon.com with PID 50314 (/Users/sumt/Desktop/Work/RandomWork/RandomProjects/target/classes started by sumt in /Users/sumt/Desktop/Work/RandomWork/RandomProjects)
  2017-12-25 16:41:16.244  INFO 50314 --- [BootMain.main()] com.spring.boot.SpringBootMain           : No active profile set, falling back to default profiles: default
  2017-12-25 16:41:16.408  INFO 50314 --- [BootMain.main()] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7bbcce75: startup date [Mon Dec 25 16:41:16 IST 2017]; root of context hierarchy
  2017-12-25 16:41:18.279  INFO 50314 --- [BootMain.main()] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
  2017-12-25 16:41:18.295  INFO 50314 --- [BootMain.main()] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
  2017-12-25 16:41:18.297  INFO 50314 --- [BootMain.main()] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.16
  2017-12-25 16:41:18.402  INFO 50314 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
  2017-12-25 16:41:18.402  INFO 50314 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2056 ms
  2017-12-25 16:41:18.560  INFO 50314 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
  2017-12-25 16:41:18.564  INFO 50314 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
  2017-12-25 16:41:18.565  INFO 50314 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
  2017-12-25 16:41:18.565  INFO 50314 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
  2017-12-25 16:41:18.566  INFO 50314 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
  2017-12-25 16:41:18.920  INFO 50314 --- [BootMain.main()] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7bbcce75: startup date [Mon Dec 25 16:41:16 IST 2017]; root of context hierarchy
  2017-12-25 16:41:19.005  INFO 50314 --- [BootMain.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity&lt;java.util.Map&lt;java.lang.String, java.lang.Object&gt;&gt; org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
  2017-12-25 16:41:19.007  INFO 50314 --- [BootMain.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
  2017-12-25 16:41:19.041  INFO 50314 --- [BootMain.main()] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  2017-12-25 16:41:19.041  INFO 50314 --- [BootMain.main()] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  2017-12-25 16:41:19.084  INFO 50314 --- [BootMain.main()] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  2017-12-25 16:41:19.323  INFO 50314 --- [BootMain.main()] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
  2017-12-25 16:41:19.407  INFO 50314 --- [BootMain.main()] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
  2017-12-25 16:41:19.413  INFO 50314 --- [BootMain.main()] com.spring.boot.SpringBootMain           : Started SpringBootMain in 3.889 seconds (JVM running for 6.196)
  </code></pre>
  
  <p>I have added base package scan and even tried with <code>@ComponentScan</code> annotation, but the result is same when I hit URL (<a href="http://localhost:8080/abc" rel="noreferrer">http://localhost:8080/abc</a>):</p>
  
  <p>There was an unexpected error (type=Not Found, status=404).
  No message available</p>
  
  <p>Did anyone else face the same issue? Please suggest as how did you solve this.</p>