title: 404 not found in RestController in Spring Boot
body: <p>I have a Spring Boot Project with pom.xml like this</p>
  
  <pre><code>&lt;groupId&gt;com.project&lt;/groupId&gt;
      &lt;artifactId&gt;prj&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
  
      &lt;name&gt;prj&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.0.3.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.h2database&lt;/groupId&gt;
              &lt;artifactId&gt;h2&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;8.0.11&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  </code></pre>
  
  <p>The Application class is like this</p>
  
  <pre><code>@SpringBootApplication
  public class PrjApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(HqApplication.class, args);
      }
  }
  </code></pre>
  
  <p>And I have a RestController where I am trying to do some CRUD Operations like this</p>
  
  <pre><code>@RestController("/register")
  public class RegisterController {
      @Autowired
      private UserRepository userRepository;
  
      @GetMapping("/user/{id}")
      public User getUser(@Valid @RequestBody Long id){
          User user = userRepository.getOne(id);
          return user;
      }
  
      @PostMapping("/new")
      public User saveUser(@Valid @RequestBody String name,@Valid @RequestBody String email,@Valid @RequestBody String password,@Valid @RequestBody String phone){
          System.out.println("savginv user");
          User user = new User();
          user.setEmail(email);
          user.setPassword(password);
          user.setName(name);
          user.setPhone(phone);
          userRepository.save(user);
          return user;
      }
  }
  </code></pre>
  
  <p>I have made an Entity class; User like this</p>
  
  <pre><code>@Entity
  @Table(name = "tbl_users")
  public class User {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      Long id;
  
      String name, email, password, phone;
  
      public Long getId() {
          return 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 getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public String getPhone() {
          return phone;
      }
  
      public void setPhone(String phone) {
          this.phone = phone;
      }
  }
  </code></pre>
  
  <p>When I try to save a user by calling the post method using PostMan it gives me 404 not found error.</p>
  
  <pre><code>{
      "timestamp": "2018-06-23T06:47:14.086+0000",
      "status": 404,
      "error": "Not Found",
      "message": "No message available",
      "path": "/prj/register/new"
  }
  </code></pre>
  
  <p>I am using JPARepository to perform Database operations.</p>