• 1000 * VehicleController
@RestController
@RequestMapping("vehicles")
public class VehicleController {
@Autowired
VehicleService vehicleService;
@RequestMapping(value = "test", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<?> test(@PathVariable("id") Long id) {
return new ResponseEntity<>(vehicleService.getById(id), HttpStatus.ACCEPTED);
}
}
Я просмотрел некоторые ответы на inte rnet, и я знаю, что проблема в том, что у меня есть @ PathVariable внутри запроса на получение и это по какой-то причине притворяется преобразует запрос GET в запрос POST, также я нашел этот ответ: Представьте, что метод GET распознается как POST , но решение не сработало для меня, и я не думаю, что это правильный способ решить эту проблему.
Трассировка стека ошибки:
vehicle-service_1 | 2020-06-18 16:48:16.087 WARN 7 --- [nio-8080-exec-6] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported]
cart-service_1 | 2020-06-18 16:48:16.259 ERROR 11 --- [nio-8080-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is feign.Fe
ignException$MethodNotAllowed: [405] during [GET] to [http://vehicle/vehicles/test] [VehicleServiceProxy#test(Long)]: [{"timestamp":"2020-06-18T16:48:16.108+0000","status":405,"error":"Method Not Allowed","message":"Request method 'POST' not supported","path":"/veh
icles/test"}]] with root cause
cart-service_1 |
cart-service_1 | feign.FeignException$MethodNotAllowed: [405] during [GET] to [http://vehicle/vehicles/test] [VehicleServiceProxy#test(Long)]: [{"timestamp":"2020-06-18T16:48:16.108+0000","status":405,"error":"Method Not Allowed","message":"Request method 'POST
' not supported","path":"/vehicles/test"}]