我的Spring Boot应用程序中有以下控制器:
@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();
}
}
当我在http://127.0.0.1:5000/users/getAll
上进行HTTP Get时,它可以正常工作:我从数据库中获取所有用户...
但是当我打电话给http://127.0.0.1:5000/users/helloWorld
时,我得到了unexpected error (type=Not Found, status=404)
http://127.0.0.1:5000/api-docs
以获取API定义时:两个端点都暴露。问题是区分大小写,当我用@GetMapping(value ="/helloWorld")
替换@GetMapping(value ="/helloworld")
时就解决了>