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,请移步官网瞧瞧。

posted @ 2021-12-25 17:59  楼兰胡杨  阅读(663)  评论(0编辑  收藏  举报