作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 stackoverflow 上发现了很多类似的问题,但答案对我没有帮助。我在 Rest api 项目中使用 JSR-303 Bean 验证来为现有 bean 类提供验证。我已经添加了所有依赖项,但收到此错误。
javax.validation.ValidationException: Unable to find a default provider
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:264)[272:wrap_mvn_javax.validation_validation-api_1.0.0.GA:0]
at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111)[272:wrap_mvn_javax.validation_validation-api_1.0.0.GA:0]
at com.uk.aviva.integration.LookupUkAddress.ValidateAddress.validateRequest(ValidateAddress.java:27)[277:ukAddress:0.0.8.SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_11]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_11]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_11]
at java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_11]
at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:407)[144:org.apache.camel.camel-core:2.12.0.redhat-611412]
at org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:278)[144:org.apache.camel.camel-core:2.12.0.redhat-611412]
at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:251)[144:org.apache.camel.camel-core:2.12.0.redhat-611412]
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:166)[144:org.apache.camel.camel-core:2.12.0.redhat-611412]
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)[144:org.apache.camel.camel-core:2.12.0.redhat-611412]
at org.apache.camel.processor.interceptor.HandleFaultInterceptor.process(HandleFaultInterceptor.java:41)[144:org.apache.camel.camel-core:2.12.0.redhat-611412]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)[144:org.apache.camel.camel-core:2.12.0.redhat-611412]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)[144:org.apache.camel.camel-core:2.12.0.redhat-611412]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[144:org.apache.camel.camel-core:2.12.0.redhat-611412]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)[144:org.apache.camel.camel-core:2.12.0.redhat-611412]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[144:org.apache.camel.camel-core:2.12.0.redhat-611412]
我看到很多人面临同样的问题,但是给出的解决方案是将 hibernate-validator 版本 4.0 或更高版本添加到类路径中。但我已经在使用 hibernate-validator 版本 5.0.1.FINAL。这是我的 pom 条目
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-annotation-processor</artifactId>
<version>5.0.1.Final</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
有什么我错过的吗?
最佳答案
所以我找到了一种避免错误的方法并且它有效。为了避免这种情况,请使用 hibernate-validator 依赖项版本 4.2.1.FINAL 和 javax.validation 版本 1.1.0.FINAL。并将这两个添加到您的类路径中。这解决了我的错误。
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.FINAL</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-annotation-processor</artifactId>
<version>4.2.0.FINAL</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
关于javax.validation.ValidationException : Unable to find a default provider - 10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30052788/
我是一名优秀的程序员,十分优秀!