我正在使用 Webflux,并将使用 bean 验证进行现场验证。
\n尝试使用响应字段错误@RestControllerAdvice
Exception在bean验证字段中指定组时\n我可以知道类型不同的原因吗?
WebExchangeBindException当未指定组时会发生异常。
当您指定组时,会ConstraintViolationException发生异常。
我想要一个统一的异常,并知道是否@RestControllerAdvice应该单独管理异常。
我查了一下。\n我不认为AbstractMessageReaderArgumentResolver使用组来验证字段...
我想要一个统一的例外,WebExchangeBindException或者ConstraintViolationException
spring-boot- 2.5.3spring-boot-starter-webflux- 5.3.9堆栈跟踪
\nPOST http://localhost:8080/api/v1/user\nContent-Type: application/json\n\n{\n "name": "12345678901",\n "age": 30,\n "address" : "test",\n "phoneNumber": "010-1234-5678"\n}\nRun Code Online (Sandbox Code Playgroud)\norg.springframework.web.bind.support.WebExchangeBindException: Validation failed for argument at index 0 in method: public reactor.core.publisher.Mono<com.example.practicejavaannotation.entity.User> com.example.practicejavaannotation.controller.UserController.create(com.example.practicejavaannotation.dto.request.UserDto), with 1 …Run Code Online (Sandbox Code Playgroud)