title: Spring component-scan not working? Mapped URL returns 404
body: <p>I am creating a Spring MVC webapp and I like to use automatic discovery of components such as controllers.</p>
  
  <p>In my application-context file I put the following tag</p>
  
  <pre><code>&lt;context:component-scan base-package="com.example" /&gt;
  </code></pre>
  
  <p>There is a controller present in com.example.springmvc.controller </p>
  
  <pre><code>@Controller
  public class AccountController  {
  
      @RequestMapping("/account.html")
      public ModelMap showAccount() throws Exception {
  
          ModelMap modelMap = new ModelMap();
          modelMap.addAttribute("someText", "This is an account");
  
          return modelMap;
      }
  
      @RequestMapping("/account.html")
      public ModelMap showAccount(@RequestParam("accountId") int accountId) throws Exception     {
  
          ModelMap modelMap = new ModelMap();
          modelMap.addAttribute("someText", String.format("This is an account with id %d", accountId));
  
          return modelMap;
      }
  
  }
  </code></pre>
  
  <p>When I test by going to localhost:8080/account.html I get a 404, so I must be forgetting something.</p>
  
  <p>When I create a custom mapping in my MVC config file, like below, than it works. At least, then I get an error about ambigious methods in the controller, but that is another problem. At least then it finds the controller.</p>
  
  <pre><code>&lt;bean name="/account.html" class="com.example.springmvc.controller.AccountController"/&gt;
  </code></pre>
  
  <p>I don't want to create my mappings in XML, I want to use annotated URL mappings. Could you tell me what I am forgetting here?</p>