Hibernate Validator 提示javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint
问题背景:Spring boot项目不想写诸多校验代码,避免代码既丑陋又繁琐,故使用hibernate validator校验参数的时候,但出现如下所示的的错误提示:
javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint
解决办法:hibernate-validator各个依赖版本不匹配,在pom.xml引入如下坐标:
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>7.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator-cdi</artifactId>
<version>7.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>jakarta.el</artifactId>
<version>4.0.1</version>
</dependency>
如上依赖信息来源于Hibernate Validator官网:Getting started with Hibernate Validator;欲使用最新jar,请移步官网瞧瞧。
读后有收获,小礼物走一走,请作者喝咖啡。
Buy me a coffee. ☕Get red packets.
作者:楼兰胡杨
本文版权归作者和博客园共有,欢迎转载,但请注明原文链接,并保留此段声明,否则保留追究法律责任的权利。