找不到Spring MVC OptionalValidatorFactoryBean [英] Spring MVC OptionalValidatorFactoryBean not found

查看:345
本文介绍了找不到Spring MVC OptionalValidatorFactoryBean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了Spring MVC(4)+ Postgresql + JPA应用程序,但遇到以下情况: 我想为我的用户"设置自定义查询因此,将这些行添加到现有(空)UserRepository中:

public interface AccountRepository extends JpaRepository<User,Long> {
    @Query("select u from User u where u.Email = ?1")
    User findByEmail(String emailAddress);

}

使用空存储库,服务器一切正常,使用上述版本时,启动时出现以下异常:

org.springframework.beans.factory.BeanCreationException:创建名称为'accountController'的bean时出错:自动连接依赖项的注入失败;

嵌套异常是

org.springframework.beans.factory.BeanCreationException:无法自动连线字段:私有com.springapp.mvc.Repositories.AccountRepository com.springapp.mvc.AccountController.accountRepository;

嵌套异常是

org.springframework.beans.factory.CannotLoadBeanClassException:找不到名称为"org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean#0"的bean的类[org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean];

嵌套异常是

java.lang.ClassNotFoundException:org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean

即使艰难,我在maven提供的jar中(提取了它)也具有OptionalValidatorFactoryBean.java.我真的很困惑.

解决方案

今天,我遇到了相同的问题,它是由jar冲突引起的. spring-context3.1-RELEASE.jar和spring-context4.1-RELEASE.jar,我的项目使用spring4.1,但是由于maven依赖关系,也下载了spring3.1-context,然后我删除了spring3.1.jar,一切顺利

Hi I have set up a Spring MVC (4)+Postgresql+JPA app and I encountered the following situation: I want to set up custom queries for my "User" repository so added these lines to the existing (empty) UserRepository:

public interface AccountRepository extends JpaRepository<User,Long> {
    @Query("select u from User u where u.Email = ?1")
    User findByEmail(String emailAddress);

}

With the empty Repository, everything is OK with the server, with the verison above I got the following exception on startup:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountController': Injection of autowired dependencies failed;

nested exception is

org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.springapp.mvc.Repositories.AccountRepository com.springapp.mvc.AccountController.accountRepository;

nested exception is

org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean] for bean with name 'org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean#0' defined in null;

nested exception is

java.lang.ClassNotFoundException: org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean

Even tough I have OptionalValidatorFactoryBean.java in the jar (extracted it) provided with maven. I'm really confused.

解决方案

today i come across the same problem , It caused by jar confliction . spring-context3.1-RELEASE.jar and spring-context4.1-RELEASE.jar , my project using spring4.1 , but spring3.1-context is also downloaded because of maven dependencies,then I remvoed spring3.1.jar ,all goes well

这篇关于找不到Spring MVC OptionalValidatorFactoryBean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆