Java Spring MVC 3 验证 - 无法找到默认提供程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2231100/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Spring MVC 3 Validation - Unable to find a default provider
提问by Kyle
I get an error when trying to set up Spring MVC validation.
尝试设置 Spring MVC 验证时出现错误。
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?
我在文档中读到他们使用的默认提供程序是 hibernate-validator。我是否需要包含此库才能进行验证?即使我的项目没有使用休眠,也可以包含这个库吗?
采纳答案by axtavt
Yes, you should include Hibernate Validator library in order to use it. It doesn't depend on Hibernate itself.
是的,您应该包含 Hibernate Validator 库才能使用它。它不依赖于 Hibernate 本身。
回答by Atonewell
Make sure you're using Hibernate 4.
确保您使用的是 Hibernate 4。
回答by STB Land
If you are using Maven, you must add a dependency to the Hibernate Validator Annotation Processor.
如果您使用 Maven,则必须向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:
您可以在JBoss 存储库中找到它:
<repository>
<id>JBoss Repository</id>
<url>https://repository.jboss.org/nexus/content/repositories/releases</url>
<name>JBoss Repository</name>
</repository>