title: when I post ,it shows error of 404 not found in spring boot even when I have declared @RequestMapping
body: <p>I have made a userservice where I want to add new user, find user by id and also by other attributes. I have extended JPA repository since I learned that there is already functions. But I can't even save a new user.</p>
  
  <p>This is my model</p>
  
  <pre><code>package bt.gov.dit.userservice.model;
  
  import javax.persistence.*;
  
  @Entity
  public class User {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column
      private Long Id;
  
      @Column
      private String name;
  
      @Column
      private String email;
  
      @Column
      private String role;
  
      public Long getId() {
          return Id;
      }
  
      public void setId(Long id) {
          Id = id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public String getRole() {
          return role;
      }
  
      public void setRole(String role) {
          this.role = role;
      }
  
      public User(Long id, String name, String email, String role) {
          Id = id;
          this.name = name;
          this.email = email;
          this.role = role;
      }
  
      public User() {
      }
  }
  </code></pre>
  
  <p>This is my repository</p>
  
  <pre><code> package bt.gov.dit.userservice.dao;
  
  import bt.gov.dit.userservice.model.User;
  import org.springframework.data.jpa.repository.JpaRepository;
  import org.springframework.stereotype.Repository;
  
  @Repository
  public interface UserRepository extends JpaRepository&lt;User,Long&gt; {
  
      User findUserByRole(String role);
  
  }
  
  </code></pre>
  
  <p>This is my service</p>
  
  <pre><code>package bt.gov.dit.userservice.service;
  import bt.gov.dit.userservice.dao.UserRepository;
  import bt.gov.dit.userservice.model.User;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  
  @Service
  public class UserService {
  
      @Autowired
      private UserRepository userRepository;
  
      public User save(User user){
  
          return userRepository.save(user);
      }
   public User getByRole(String role){
          return userRepository.findUserByRole(role);
      }
  }
  </code></pre>
  
  <p>And this is my Controller</p>
  
  <pre><code>package bt.gov.dit.userservice.controller;
  
  import bt.gov.dit.userservice.model.User;
  //import bt.gov.dit.userservice.service.UserService;
  import bt.gov.dit.userservice.service.UserService;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.http.HttpHeaders;
  import org.springframework.http.HttpStatus;
  import org.springframework.http.ResponseEntity;
  import org.springframework.web.bind.annotation.*;
  
  import javax.validation.Valid;
  
  @RestController
  @RequestMapping("/api")
  
  public class UserController {
  
      @Autowired
      private UserService userService;
  
      @PostMapping
      public ResponseEntity&lt;User&gt; create(@Valid @RequestBody User user) {
  
          User updated = userService.create(user);
          return new ResponseEntity&lt;User&gt;(updated, new HttpHeaders(), HttpStatus.OK);
  
      }
  
      @GetMapping("/{role_id}")
      public ResponseEntity&lt;User&gt; getUserByRole(@PathVariable("role_id") String role)
      {
          User entity = userService.getByRole(role);
  
          return new ResponseEntity&lt;User&gt;(entity, new HttpHeaders(), HttpStatus.OK);
      }
  }
  
  </code></pre>
  
  <p>I have just started learning Spring boot and I can't seem to understand what is wrong in code. I want to insert/save new user. But when I call /api/user it says 404 not found. I am using h2 in-memory db. </p>