title: Receiving 404 for RestControllers in spring
body: <p>I am new to Spring MVC and trying to build a basic hello world example Using AngularJS and SpringMVC (Uisng Maven and Eclipse). 
  After going through some tutorials on internet I have done following things </p>
  
  <p>Web MVC Configurations </p>
  
  <pre><code>@Configuration
  @EnableWebMvc
  public class WebMvcConfig extends WebMvcConfigurerAdapter {
  
      @Override
      public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
          configurer.enable();
      }
  
      @Override
      public void addResourceHandlers(ResourceHandlerRegistry registry) {
          registry.addResourceHandler("/webjars/**").addResourceLocations("/webjars/")
              .resourceChain(false)
                  .addResolver(new WebJarsResourceResolver())
                  .addResolver(new PathResourceResolver());
      }
  }
  </code></pre>
  
  <p>Servlet Initializer</p>
  
  <pre><code>    public class SampleInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
  
      @Override
      protected Class&lt;?&gt;[] getRootConfigClasses() {
          return new Class[] { WebMvcConfig .class };
      }
  
      @Override
      protected Class&lt;?&gt;[] getServletConfigClasses() {
          return null;
      }
  
      @Override
      protected String[] getServletMappings() {
          return new String[] { "/" };
      }
  
      @Override
      protected Filter[] getServletFilters() {
          Filter [] singleton = { new CORSFilter() };
          return singleton;
      }
  
  }
  </code></pre>
  
  <p>CORS Filter </p>
  
  <pre><code>public class CORSFilter implements Filter {
  
      public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
          HttpServletResponse response = (HttpServletResponse) res;
          response.setHeader("Access-Control-Allow-Origin", "*");
          response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE");
          response.setHeader("Access-Control-Max-Age", "3600");
          response.setHeader("Access-Control-Allow-Headers", "x-requested-with, Content-Type");
          chain.doFilter(req, res);
      }
  
      public void init(FilterConfig filterConfig) {}
  
      public void destroy() {}
  
  }
  </code></pre>
  
  <p>SampleController :</p>
  
  <pre><code>@RestController
  public class SampleController {
  
  
      @RequestMapping(path = "/sample", method = RequestMethod.GET)
      public List&lt;String&gt; listUsers() {
          List&lt;String&gt; result = new ArrayList&lt;&gt;();
          result.add("user1");
          return result;
      }
  
  }
  </code></pre>
  
  <p>Webapp structure</p>
  
  <p><a href="https://i.stack.imgur.com/Fref5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Fref5.png" alt="enter image description here"></a>
  app.js [Routing using route provider - code Snippet]</p>
  
  <pre><code>angular
          .module('app', ['ngRoute', 'ngCookies' ,'ngTable'])
          .config(config)
          .run(run);
  
      config.$inject = ['$routeProvider', '$locationProvider'];
      function config($routeProvider, $locationProvider) {
          $routeProvider
              .when('/', {
                  controller: 'HomeController',
                  templateUrl: 'home/home.view.html',
                  controllerAs: 'vm'
              })
  
              .when('/login', {
                  controller: 'LoginController',
                  templateUrl: 'login/login.view.html',
                  controllerAs: 'vm'
              })
  </code></pre>
  
  <p>Tomcat Settings :</p>
  
  <p>Since there is no WEB-INF/web.xml , I have removed it from 
  tomcat-8\conf\context.xml </p>
  
  <pre><code>    &lt;!-- Default set of monitored resources. If one of these changes, the--&gt;
      &lt;!-- web application will be reloaded.--&gt;
      &lt;!--&lt;WatchedResource&gt;WEB-INF/web.xml&lt;/WatchedResource&gt;--&gt;
      &lt;WatchedResource&gt;${catalina.base}/conf/web.xml&lt;/WatchedResource&gt;
  </code></pre>
  
  <p>In tomcat-8\conf\web.xml I see that index.html has been mentioned as Welcome file </p>
  
  <p>When I deploy my application to tomcat , its able to display index.html and due to my routing code , its able to route to login.html . But when I am trying to access the rest service , it shows 404 HTTP Status .</p>
  
  <p>Is there some other setting which I need to maintain somewhere ?
  I have re-checked my RestService code and it seems to be correct to me. Also I have checked the tomcat log and it doesn't shows any error either.</p>
  
  <p>Also If possible , can you please point me to a good step by step tutorial of using AngularJS with Spring based Rest Services (Using maven )     </p>