没有类型为'java.lang.Class< org.springframework.data.repository.Repository<?,?>>'的合格Bean [英] No qualifying bean of type 'java.lang.Class<org.springframework.data.repository.Repository<?, ?>>'

查看:203
本文介绍了没有类型为'java.lang.Class< org.springframework.data.repository.Repository<?,?>>'的合格Bean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用程序取决于许多spring数据项目,包括Neo4j,Solr和Jpa.我最近不得不将spring-data-solr更新为Snapshot-3.0.0.M1(以消除另一个依赖冲突).我认为传递依赖项之一导致与neo4j发生冲突.如果我从项目中删除spring-neo4j,错误(见下文)似乎就消失了.

Application depends on a number of spring data projects including Neo4j, Solr and Jpa. I recently had to update spring-data-solr to Snapshot-3.0.0.M1 (to eliminate another dependency conflict). I think one of the transitive dependency is causing a conflict with neo4j. If I remove spring-neo4j from project, error (see below) seem to go away.

我附有一个重新创建问题的示例项目.运行测试类AccountServiceJpaTester.testSaveAccount()

I have a attached a sample project that recreates the issue. Run Test Class AccountServiceJpaTester.testSaveAccount()

此处

原因:org.springframework.beans.factory.NoSuchBeanDefinitionException:没有类型为"java.lang.Class>"的合格bean:期望至少有1个有资格作为自动装配候选的bean.依赖注释:{} 在org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1456) 在org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1087) 在org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1049) 在org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:833)上 在org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:740) ...还有60个

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.lang.Class>' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1456) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1087) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1049) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:833) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:740) ... 60 more

推荐答案

Spring数据项目均基于通用基础架构(Spring数据通用). 如果您使用spring数据系列中的多个项目(在您的情况下为neo4j,solr,jpa),则必须确保它们均基于基础结构的通用版本.

Spring data projects are all based on a common infrastructure (spring data commons). If you use several projects in the spring data family (in your case neo4j, solr, jpa), you have to make sure they are all based on a common version of the infrastructure.

在您的情况下,spring-data-solr 3.0.0 M1是基于spring-data-commons 2.x的,而JPA和Neo4j使用的是spring-data-commons 1.x.

In your case, spring-data-solr 3.0.0 M1 is based on spring-data-commons 2.x whereas JPA and Neo4j use spring-data-commons 1.x.

管理此问题的一种好方法是使用spring数据BOM.在 spring数据首页中对此进行了说明. To manage the portfolio, a BOM (Bill of Materials - see this example) is published with a curated set of dependencies on the individual project 如果您需要更新到BOM表中所含版本之外的较新版本,请确保它们基于相同的基础结构版本.

A good way of managing this is to use the spring data BOM. This is explained on the spring data homepage. To manage the portfolio, a BOM (Bill of Materials - see this example) is published with a curated set of dependencies on the individual project If you need to update to newer versions than the ones included in the BOM, make sure they are based on the same infrastructure version.

这篇关于没有类型为'java.lang.Class< org.springframework.data.repository.Repository<?,?>>'的合格Bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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