javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint
javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint
使用hibernate validator出现上面的错误, 一般两种情况:
(1)注解与需要校验的数据类型不匹配,然后就会找不到。譬如在String 类型上使用@Min
org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree#getConstraintValidatorNoUnwrapping
org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager#getInitializedValidator
org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager#findMatchingValidatorClass
org.hibernate.validator.internal.util.TypeHelper#extractType
org.hibernate.validator.internal.util.TypeHelper#getValidatorsTypes
(2)validation-api和hibernate-validator的版本不匹配。导致注解没有对应的Validator。譬如:validation-api2.x已经收录了@javax.validation.constraints.NotEmpty,但hibernate-validator 5.x中还没有相应的Validator。
hibernate-validator 5.x中是使用组合注解的方式来处理@org.hibernate.validator.constraints.NotEmpty
如下图所示,@javax.validation.constraints.NotEmpty是没有对应的Validator的,如果使用肯定会报 Novalidator
温馨提示:Spring boot 中spring-boot-starter-web 中已经匹配的版本。如果不在pom.xml新增validation-api和hibernate-validator就不会出现版本不匹配
配套的版本:
(1)validation-api 1.1.0.Final + hibernate-validator 5.3.6.Final
(2)validation-api 2.0.1.Final + hibernate-validator 6.0.16.Final
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.16.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
如果在基本类型上面用NotEmpty或者NotBlank 会出现上面的错
http://blog.csdn.net/dracotianlong/article/details/23181729
javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 'javax.validation.constraints.Size' validating type 'java.lang.Short'. Check configuration for 'status'
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.throwExceptionForNullValidator(ConstraintTree.java:229)
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.getConstraintValidatorNoUnwrapping(ConstraintTree.java:310)
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.getConstraintValidatorInstanceForAutomaticUnwrapping(ConstraintTree.java:244)
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.getInitializedConstraintValidator(ConstraintTree.java:163)
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:116)
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateComposingConstraints(ConstraintTree.java:398)
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:98)
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:87)
at org.hibernate.validator.internal.metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java:73)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateMetaConstraint(ValidatorImpl.java:617)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:580)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForSingleDefaultGroupElement(ValidatorImpl.java:524)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:492)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:457)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:407)
at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:205)
at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:108)
at org.springframework.validation.DataBinder.validate(DataBinder.java:866)
at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.validateIfApplicable(ModelAttributeMethodProcessor.java:164)
at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:111)
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:99)
at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:161)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:128)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:817)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:731)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968)
at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:881)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:651)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint的更多相关文章
- javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 解决方法
在使用hibernate validator进行参数有效性校验的时候,我们有时候会遇到javax.validation.UnexpectedTypeException: HV000030: No va ...
- javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 'javax.validation.constraints.Size' validating type 'java.util.Date'.
开始是 javax.validation.UnexpectedTypeException: No validator could be found for type: java.lang.Intege ...
- javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint,NotBlank判断不能为空
java 验证出现如下错误: javax.validation.UnexpectedTypeException: HV000030: No validator could be found for c ...
- hibernate 验证异常 javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint
使用hibernate validator出现上面的错误, 需要 注意 @NotNull 和 @NotEmpty 和@NotBlank 区别 @NotEmpty 用在集合类上面@NotBlank 用 ...
- javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint-实体报错
使用hibernate validator出现上面的错误, 需要 注意 @NotNull 和 @NotEmpty 和@NotBlank 区别 @NotEmpty 用在集合类上面@NotBlank 用 ...
- 【SpringMVC】数据校验时,抛出javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: java.util.Date.
老魏原创,转载请留言. 原因:给Javabean中的字段注解多余或者错误导致. @NotEmpty @Past @DateTimeFormat(pattern="yyyy-MM-dd&quo ...
- 使用spring jpa hibernate框架时报错:javax.validation.UnexpectedTypeException: HV000030
错误信息: [#%&*^]20190521121942:497.!react:all.,RctJobExecutor-1#D9AA5167921A464CA9DDA14943545426%NA ...
- Validation异常:No validator could be found for constraint '.....' validating type 'java.lang.Integer'.
javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 'java ...
- spring boot中使用javax.validation以及org.hibernate.validator校验入参
这里springboot用的版本是:<version>2.1.1.RELEASE</version> 自带了hibernate.validator,所以不用添加额外依赖 1.创 ...
随机推荐
- Hiberante+jpa,注解生成32字符的Id
@Id @GenericGenerator(name = "id-generator", strategy = "uuid") @GeneratedValue( ...
- Entity Framework4.0 (六) EF4的 增加、删除、更改
前面介绍了EF4的查询功能,主要是借助于LINQ的强大的查询功能和它简单的语法.让我们可以完全面向对象集体去进行查询,而不必去劳心处理那些关系型数据库表的操作.这样我们更容易把主要精力集中在业务逻辑上 ...
- matlab实现判断是否能否生成严格对角占优矩阵
如题: function X = IsStrictDiagMatrix(A) % input: A matrix % output: The matrix after transformation % ...
- 微软职位内部推荐-Senior Speech TTS
微软近期Open的职位: Job Description: Responsibilities Do you want to change the way the world interacts wit ...
- JPA学习---第六节:大数据字段映射与字段延迟加载
1.大数据字段所需的注解 @Lob ,例如: @Lobprivate String info; 在mysql中映射产生的字段的类型是longtext:在oracle中是 CLOB @Lobpriva ...
- C# Double toString保留小数点方法
有时候double型数据需要toString(),但又想保留小数,当值为整数,比如3.00时tostring后会变为”3″,具体说明见下: 1 string str0 = i.ToString(&qu ...
- VBS基础篇 - Err对象
Err对象是一个具有全局范围的内部对象,含有关于错误的所有信息.On Error Resume next 忽略运行时产生的所有错误On Error Goto 0 取消忽略错误措施主要方法有:Clear ...
- 一次失败的面试——IBM电话面试
前几天接到IBM的电话面试了,虽然被PASS了,还是发个博记录一下吧.这大概是我第一次比较正式的面试了,虽然只是通过电话,但是还是暴露出了自己的很多问题,总结下,前事不忘,后事之师嘛.:) 一号上午接 ...
- tomcat7.0.47 修改tomcat窗口名称
最近使用的是 apache - tomcat 集群,为了方便管理上想要修改tomcat命令窗口的名字来区分不同的tomcat,我在网上找了些资料,顺便总结一下,方便自己,方便他人 修改如下: 找到to ...
- 【BZOJ】【2157】旅游
LCT 直到动手写拆边为点的时候才发现根本不会写……去orz了一下Hzwer(话说这题应该也用不着LCT吧……下次再换种姿势写一遍好了) /****************************** ...