title: Why do I get 404 for rest with spring-boot
body: <p>I am implementing rest services with Spring Boot. The entity classes are defined in a separate package. So I added that with Component annotation in Application.java.</p>
  
  <pre><code>@Configuration
  @EnableAutoConfiguration
  @ComponentScan("org.mdacc.rists.cghub.model")
  @EnableJpaRepositories(basePackages = "org.mdacc.rists.cghub.model") 
  public class Application 
  {
      public static void main( String[] args )
      {
          SpringApplication.run(Application.class, args);
      }
  }
  </code></pre>
  
  <p>Here is my controller class:</p>
  
  <pre><code>// SeqController.java
  @RestController
  public class SeqController {
  
      @Autowired
      private SeqService seqService;
      @RequestMapping(
              value = "/api/seqs", 
              method = RequestMethod.GET, 
              produces = MediaType.APPLICATION_JSON_VALUE)
      public ResponseEntity&lt;List&lt;SeqTb&gt;&gt; getSeqs() {
          List&lt;SeqTb&gt; seqs = seqService.findAll();
  
          return new ResponseEntity&lt;List&lt;SeqTb&gt;&gt;(seqs, HttpStatus.OK);
      }
  }
  </code></pre>
  
  <p>I also created a JPA data repository that extends JPARepository in which I added custom query code.</p>
  
  <pre><code>// SeqRepository.java
  @Repository
  public interface SeqRepository extends JpaRepository&lt;SeqTb, Integer&gt; {
  
      @Override
      public List&lt;SeqTb&gt; findAll();
  
      @Query("SELECT s FROM SeqTb s where s.analysisId = :analysisId")
      public SeqTb findByAnalysisId(String analysisId);
  }
  </code></pre>
  
  <p>Below is the servicebean class that implements a service interface</p>
  
  <pre><code>// SeqServiceBean.java
  @Service
  public class SeqServiceBean implements SeqService {
      @Autowired
      private SeqRepository seqRepository;
  
      @Override
      public List&lt;SeqTb&gt; findAll() {
          List&lt;SeqTb&gt; seqs = seqRepository.findAll();
          return seqs;
      }
  
      public SeqTb findByAnalysisId(String analysisId) {
          SeqTb seq = seqRepository.findByAnalysisId(analysisId);
          return seq;
      }
  }
  </code></pre>
  
  <p>When I started the application and type the following url in the browser "<a href="http://localhost:8080/api/seqs" rel="nofollow">http://localhost:8080/api/seqs</a>" , I got 404 error. What did I miss?</p>
  
  <p>Edit #1:
  I decided to take out the JPA repository stuff and change the controller class to the following:</p>
  
  <pre><code>@RestController
  //@RequestMapping("/")
  public class SeqController {
      private static BigInteger nextId;
      private static Map&lt;BigInteger, Greeting&gt; greetingMap;
  
      private static Greeting save(Greeting greeting) {
          if(greetingMap == null) {
              greetingMap = new HashMap&lt;BigInteger, Greeting&gt;();
              nextId = BigInteger.ONE;
          }
          greeting.setId(nextId);
          nextId = nextId.add(BigInteger.ONE);
          greetingMap.put(greeting.getId(), greeting);
          return greeting;
      }
  
      static {
          Greeting g1 = new Greeting();
          g1.setText("Hello World!");
          save(g1);
  
          Greeting g2 = new Greeting();
          g1.setText("Hola Mundo!");
          save(g2);
  
      }
      @RequestMapping(
              value = "/api/greetings", 
              method = RequestMethod.GET, 
              produces = MediaType.APPLICATION_JSON_VALUE)
      public ResponseEntity&lt;Collection&lt;Greeting&gt;&gt; getGreetings() {
          Collection&lt;Greeting&gt; greetings = greetingMap.values();
          return new ResponseEntity&lt;Collection&lt;Greeting&gt;&gt;(greetings, HttpStatus.OK);
  
      }
  }
  </code></pre>
  
  <p>When I started the application and put "localhost:8080/api/greetings" in my browser I still got 404.</p>