简体   繁体   English

Hibernate验证和Spring 3.x

[英]Hibernate Validation and Spring 3.x

I am trying to use validation with Spring 3.x. 我试图在Spring 3.x中使用验证。

I have annotated a method field with @Valid , added <mvc:annotation-driven/> to my common.xml , and added Hibernate-Validator.jar in the lib/ dir, but I keep getting this message: "Hibernate validator not found: ignoring" . 我已经用@Valid注释了一个方法字段,将<mvc:annotation-driven/>添加到我的common.xml ,并在lib/目录中添加了Hibernate-Validator.jar ,但是我一直收到以下消息: "Hibernate validator not found: ignoring"

Am I missing something? 我想念什么吗?

  [Version:15] Hibernate Annotations 3.4.0.GA
  [Environment:543] Hibernate 3.3.0.SP1
  [Environment:576] hibernate.properties not found
  [Environment:709] Bytecode provider name : javassist
  [Environment:627] using JDK 1.4 java.sql.Timestamp handling
  [Version:14] Hibernate Commons Annotations 3.1.0.GA
  [AnnotationConfiguration:369] Hibernate Validator not found: ignoring

It means that Hibernate can't find the classes org.hibernate.validator.ClassValidator or org.hibernate.validator.MessageInterpolator , hinting that there's a problem with the library versions in your classpath. 这意味着Hibernate找不到类org.hibernate.validator.ClassValidatororg.hibernate.validator.MessageInterpolator ,暗示您的类路径中的库版本存在问题。

I see you're using the following versions: 我看到您使用的是以下版本:

  • Hibernate Annotations 3.4.0.GA 休眠注释3.4.0.GA
  • Hibernate 3.3.0.SP1 休眠3.3.0.SP1
  • Hibernate Commons Annotations 3.1.0.GA 休眠公用注释3.1.0.GA

And your JAR is hibernate-validator-4.0.2.GA.jar . 您的JAR为hibernate-validator-4.0.2.GA.jar Are you sure that all of these versions are compatible with each other? 您确定所有这些版本相互兼容吗?

Please try downloading the newest versions of the different Hibernate components, put them in your classpath and see if the error is still there. 请尝试下载不同的Hibernate组件的最新版本,将它们放在您的类路径中,然后查看错误是否仍然存在。

At last, I found the answer at Spring ROO Issue Tracker 最后,我在Spring ROO Issue Tracker中找到了答案

it is a bug in Hibernate that is known to be corrected in Hibernate 3.5 它是已知在Hibernate 3.5中已纠正的Hibernate中的错误。

I've this message too in my Spring project, but validation still works. 我的Spring项目中也有此消息,但验证仍然有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM