我的课程中有这个参数:
@Past
private ZonedDateTime activityDate;
尝试保存到DB时,抛出以下异常:
javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: java.time.ZonedDateTime.
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager.verifyResolveWasUnique(ConstraintValidatorManager.java:218)
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager.findMatchingValidatorClass(ConstraintValidatorManager.java:193)
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager.getInitializedValidator(ConstraintValidatorManager.java:97)
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:125)
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:91)
at org.hibernate.validator.internal.metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java:83)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:547)
任何人都可以解释为什么会这样,有没有办法让这个工作?或者我是否需要手动验证ZonedDateTime?
为了确保我在我的类路径中同时拥有org.hibernate:hibernate-core:5.0.3.Final和org.hibernate:hibernate-java8:5.0.3.Final,它们是目前最新的。
答案 0 :(得分:0)