Open Feign FeignException$MethodNotAllowed: status 405 reading Xxx#xxx()

created at 05-18-2022 views: 25

problem description

feign.FeignException$MethodNotAllowed: status 405 reading UserService#getUserList()

problem analysis

1) The called interface address consists of multiple parts. For example, the project is configured with the /base address, the Controller is configured with the /user address, the interface is configured with the /getUserList address, and the called interface address is only configured with /getUserList address, resulting in an error.

@PostMapping("/getUserList")
List<User> getUserList();

solution

You can configure the correct path by calling the interface.

@PostMapping("/base/user/getUserList")
List<User> getUserList();

2) The called interface is a Get request, the parameters are not annotated with @RequestParam, and the parameters of the calling interface are not annotated with @RequestParam, resulting in an error.

@GetMapping("/base/user/getUserList")
List<User> getUserList(User user);

solution

Parameters can be annotated with @RequestParam.

@GetMapping("/base/user/getUserList")
List<User> getUserList(@RequestParam User user);
created at:05-18-2022
edited at: 06-02-2022: