gpt4 book ai didi

spring - 得到错误 java.lang.NoClassDefFoundError : org/hibernate/validator/resourceloading/ResourceBundleLocator

转载 作者:行者123 更新时间:2023-12-02 17:44:07 27 4
gpt4 key购买 nike

我有一个 spring 项目,我在其中使用如下 validator :

<beans:bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"  
p:basenames="WEB-INF/i18n/messages,WEB-INF/i18n/application"
p:fallbackToSystemLocale="false" />

<beans:bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<beans:property name="validationMessageSource" ref="messageSource" />
</beans:bean>

<annotation-driven validator="validator" />

<resources location="/, classpath:/META-INF/web-resources/" mapping="/resources/**" />

当我运行该项目时,我得到以下 BeanCreationException:

org.springframework.beans.factory.BeanCreationException: Error creating bean with
name 'validator' defined in ServletContext resource [/WEB-INF/spring/appServlet
/servlet-context.xml]: Error setting property values; nested exception is
org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are:

PropertyAccessException 1: org.springframework.beans.MethodInvocationException:
Property 'validationMessageSource' threw exception; nested exception is
java.lang.NoClassDefFoundError: org/hibernate/validator/resourceloading/ResourceBundleLocator

这是我的 POM 片段:

<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.3.2.RELEASE</version>
</dependency>
<!-- Hibernate entity manager with JPA 2 support. -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.0.Beta2</version>
</dependency>

<!-- Hibernate’s implementation of JSR-303. -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.Final</version>
</dependency>

<!-- The JSR-303 Bean Validation API library. -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>

为什么会出现这个错误?

谢谢

最佳答案

您的依赖项没问题。根据提供的信息,错误不应出现。

所以我建议您检查您的 IDE,看看 hibernate-validator 依赖项是否真的在类路径上。如果您将 Eclipse 与 M2E 一起使用,请尝试更新您的项目:

  • 项目(右键单击项目)> Maven > 更新项目...

关于spring - 得到错误 java.lang.NoClassDefFoundError : org/hibernate/validator/resourceloading/ResourceBundleLocator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17063211/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com