0

I have the following controller in my Spring Boot application :

@RestController
@RequestMapping(value = "/users")
public class UserController {

@Autowired
UserService userService;

@GetMapping(value ="/helloWorld")
public String getHelloWorld() {
    return "Hello World!";
}

@GetMapping(value = "/getAll")
public @ResponseBody
Iterable<User> getAllInvestors() {
    return userService.getAllUsers();
}
}

When I make an HTTP Get on http://127.0.0.1:5000/users/getAll, it works perfectly : I get all the users from the database...

but when I make a call on http://127.0.0.1:5000/users/helloWorld, I get an unexpected error (type=Not Found, status=404)

  • PS 1 : When I call http://127.0.0.1:5000/api-docs to get the API definition : Both endpoints are exposed.
  • PS 2 : I've already made a Maven Clean, restarted IntelliJ, deleted all cookies from the browser.
  • PS 3 : No errors during compilation.
Radhwen
  • 232
  • 4
  • 15

1 Answers1

0

The issue was the case sensitivity, it was solved when I replaced @GetMapping(value ="/helloWorld") with @GetMapping(value ="/helloworld")

Refer to this topic for further details

Radhwen
  • 232
  • 4
  • 15
  • The details given in the question is actually correct. The issue was with the way you were making the request , nothing code related ( `getAll` works ) – R.G Apr 21 '20 at 02:45