You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级Hibernate Validator遇HV000151:接口参数校验约束未继承

问题说明

升级至最新版本后,使用spring-boot-starter-validation依赖中的hibernate-validator进行参数校验时,出现如下错误:

jakarta.validation.ConstraintDeclarationException: HV000151: A method overriding another method must not redefine the parameter constraint configuration, but method Controller#method(List, String) redefines the configuration of Controller#method(List, String).

该错误源于实现接口方法时重复定义了参数约束,但移除实现类中的参数约束后,本应从接口继承的参数校验规则并未生效。

接口代码

ResponseEntity<Object> method(
    @ApiParam(value = "Request Body", required = true) 
    @RequestBody @Valid List<Object1> request, 
    @ApiParam("language of the (Exception Detail) response ") 
    @RequestParam(value = "lang", required = false) @Valid String lang);

实现类代码(已移除参数约束)

@Override
public ResponseEntity<Object> method(List<Object1> request, String lang) {
    return new ResponseEntity<>(handler.method2(request, lang), httpHeaders, HttpStatus.CREATED);
}

内容的提问来源于stack exchange,提问作者mxverik

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 21:54:54