HV000030: No validator could be found for type: java.lang.Long(解决)
在使用hibernate validator后台校验时出现如下错误
javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: java.lang.Long. at org.hibernate.validator.internal.engine.ConstraintTree.verifyResolveWasUnique(ConstraintTree.java:411) at org.hibernate.validator.internal.engine.ConstraintTree.findMatchingValidatorClass(ConstraintTree.java:392) at org.hibernate.validator.internal.engine.ConstraintTree.getInitializedValidator(ConstraintTree.java:350) at org.hibernate.validator.internal.engine.ConstraintTree.validateConstraints(ConstraintTree.java:171) at org.hibernate.validator.internal.engine.ConstraintTree.validateComposingConstraints(ConstraintTree.java:259) at org.hibernate.validator.internal.engine.ConstraintTree.validateConstraints(ConstraintTree.java:154) at org.hibernate.validator.internal.engine.ConstraintTree.validateConstraints(ConstraintTree.java:124) at org.hibernate.validator.internal.metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java:85) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:463) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForNonDefaultGroup(ValidatorImpl.java:436) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:367) at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:322) at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:152) at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:108) at org.springframework.validation.DataBinder.validate(DataBinder.java:781)
原因是在实体类Long类型的属性使用了@NotEmpty
@NotEmpty private Long roleId;
需要改成@NotNull
@NotNull private Long roleId;
参考资料:http://blog.csdn.net/dracotianlong/article/details/23181729
需要注意@NotEmpty不能用于Long Integer 等基础数据类型,需要使用@NotNull
来源://作者:/更新时间:2015-04-21
顶
踩
相关文章:
- java使用点(.)做分割符出现throw Exception(java.lang
- springmvc 后台参数校验 使用用注解方式及国际化的写
- 解决 org.springframework.beans.factory.BeanNotOfRe
- 解决 org.springframework.beans.factory.BeanCreatio
- 【解决】Caused by: org.apache.tiles.definition.Def
- springmvc controller跳转到下一个controller,action
- 解决java.util.concurrent.ExecutionException: org.a
- 解决com.fasterxml.jackson.databind.JsonMappingExce
- springmvc controller返回字符串乱码
- junit java.lang.NoClassDefFoundError: net/minidev/