Spring MVC 3 Validation - Unable to find a default provider

天大地大妈咪最大 提交于 2019-11-27 13:29:08

问题


I get an error when trying to set up Spring MVC validation.

javax.validation.ValidationException: Unable to find a default provider

I read in the documents that the default provider they use is the hibernate-validator. Do I need to include this library to get validation to work? Is it okay to include this library even though i'm not using hibernate for my project?


回答1:


Yes, you should include Hibernate Validator library in order to use it. It doesn't depend on Hibernate itself.




回答2:


If you are using Maven, you must add a dependency to the Hibernate Validator Annotation Processor.

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-validator-annotation-processor</artifactId>
  <version>4.1.0.Final</version>
</dependency>

You can find it in the JBoss repository :

<repository>
  <id>JBoss Repository</id>
  <url>https://repository.jboss.org/nexus/content/repositories/releases</url>
  <name>JBoss Repository</name>
</repository>



回答3:


Make sure you're using Hibernate 4.



来源:https://stackoverflow.com/questions/2231100/spring-mvc-3-validation-unable-to-find-a-default-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!