Spring 启动 - 不支持请求方法 'POST'。

Spring boot - Request method 'POST' not supported.

请问我在尝试创建客户时遇到此错误。有人能帮我吗?可能是我错过了一些东西。到目前为止,我什至尝试将 @PostMapping 更改为 @RequestMapping。谢谢

我的控制器代码

`@PostMapping("CREATE_CUSTOMER_ENDPOINT")
   @ResponseStatus(value = HttpStatus.OK)
   @ApiResponses(value = {
        @ApiResponse(code = 201, message = "The Customer was Created", response = CustomerDto.class),
        @ApiResponse(code = 400, message = "Bad Request", response = ResponseError.class),
        @ApiResponse(code = 500, message = "Unexpected error")
})
  public ResponseEntity createCustomer(final HttpServletRequest request, @RequestBody CustomerDto customerDto)
{
    if (log.isDebugEnabled()){
        log.debug("[CustomerResource] POST {} : Creating customer ", CREATE_CUSTOMER_ENDPOINT);
    }

    if(customerDto.getUidpk()!=null) {
        ResponseError error  = new ResponseError(HttpStatus.BAD_REQUEST.getReasonPhrase(), "A customer Already exist with an Uidpk");
        log.error("[CustomerResource] The customer Already exist ({}) with an Uidpk", customerDto.getUidpk());
        return new ResponseEntity<>(error, null,    HttpStatus.BAD_REQUEST);
    }

    CustomerDto result = customerService.createCustomer(customerDto);
    log.debug("[CustomerResource] Customer created ({})", result.getUidpk());
    return new ResponseEntity<>(result, HeaderUtil.putLocationHeader(request.getRequestURL().toString() + "/" + result.getUidpk()), HttpStatus.CREATED);

} `

我的端点

private static final String CUSTOMER_SEARCH_USER_ID_ENDPOINT = "/customers/{userId:.+}"; private static final String CREATE_CUSTOMER_ENDPOINT= "/customer"; private static final String UPDATE_CUSTOMER_ENDPOINT= "/customer"; private static final String DELETE_CUSTOMER_ENDPOINT = CREATE_CUSTOMER_ENDPOINT + "/{uidpk}";

这是邮递员的回复 Postman sample

当您在 HTTP 请求中发送 JSON 负载时,您需要指定 Content-Type HTTP header 值为 application/json.