Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java ControllerAdvice行为不确定性的Spring引导验证_Java_Spring_Validation_Spring Boot - Fatal编程技术网

Java ControllerAdvice行为不确定性的Spring引导验证

Java ControllerAdvice行为不确定性的Spring引导验证,java,spring,validation,spring-boot,Java,Spring,Validation,Spring Boot,我有以下设置 @ControllerAdvice public class AppControllerAdvice extends ResponseEntityExceptionHandler { @ExceptionHandler({UserInputValidationException.class}) public ResponseEntity<UserInputValidationResponseBody> handleBadInputException(U

我有以下设置

@ControllerAdvice
public class AppControllerAdvice extends ResponseEntityExceptionHandler {

    @ExceptionHandler({UserInputValidationException.class})
    public ResponseEntity<UserInputValidationResponseBody> handleBadInputException(UserInputValidationException ex, WebRequest request) {
        return new ResponseEntity<>(
                new UserInputValidationResponseBody().setFieldErrors(ex.getFieldErrors()),
                HttpStatus.BAD_REQUEST
        );
    }

}
我想要绑定的POJO上有JSR-303验证注释,Spring在绑定时在请求参数绑定期间正确地验证它们

然而。。。当我让这个设置运行了一段时间后,Spring随机开始绕过@RestController和@ControllerAdvice

现在我似乎收到了org.springframework.web.bind.MethodArgumentNotValidException。。。i、 e.请求被短路

我正在运行Spring Boot 1.5.4.RELEASE

编辑下面的建议,我补充道

给管制员的建议。。。这只会让事情变得更糟。现在绝对没有验证错误-客户端只收到一条空白消息,在当前问题出现之前的一段时间内,这是问题的症状,没有任何代码更改

An Errors/BindingResult argument is expected to be declared immediately after the model attribute, the @RequestBody or the @RequestPart arguments to which they apply: public org.springframework.http.ResponseEntity com.remo.api.portfolios.PortfolioController.put(java.security.Principal,org.springframework.validation.BindingResult,com.remo.api.portfolios.Portfolio
tl;dr请继续,并确保在BindingResult之前立即声明@RequestBody

@Order(Ordered.HIGHEST_PRECEDENCE)
An Errors/BindingResult argument is expected to be declared immediately after the model attribute, the @RequestBody or the @RequestPart arguments to which they apply: public org.springframework.http.ResponseEntity com.remo.api.portfolios.PortfolioController.put(java.security.Principal,org.springframework.validation.BindingResult,com.remo.api.portfolios.Portfolio