加载Spring应用程序时发生此错误。我检查了相应bean的所有构造函数参数(PerformanceSchedulePoster)。这里我使用了五个构造函数参数,并且所有五个构造函数参数都是不同类型的。任何人都可以帮助我解决依赖问题。我附上了以下日志:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.enttek.unified.rest.server.handler.AssembledMethodHandlerFactory#111bcbb' defined in class path resource [spring/imports/backOfficeWebServices-spring.xml]: Cannot resolve reference to bean 'PerformanceSchedulePoster' while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'PerformanceSchedulePoster' defined in class path resource
[spring/imports/backOfficeWebServices-spring.xml]: Unsatisfied dependency expressed through constructor argument with index 3 of type [com.enttek.framework.util.plugin.ServiceFactory]: Ambiguous constructor argument types - did you specify the correct bean references as constructor arguments?
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:630)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270)
... 138 more
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'PerformanceSchedulePoster' defined in class path resource [spring/imports/backOfficeWebServices-spring.xml]: Unsatisfied dependency expressed through constructor argument with index 3 of type [com.enttek.framework.util.plugin.ServiceFactory]: Ambiguous constructor argument types - did you specify the correct bean references as constructor arguments?
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:716)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:196)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 146 more
答案 0 :(得分:-1)
每当遇到此类错误时,请参阅存储库中使用的字段名称,服务层中的字段名称与实体字段名称相同。
例如,
我将实体中的字段名称声明为userFullInfo
我使用并在存储库中定义为userInfo
并在服务层中调用repository.findByUserInfo_Id();
那么你会得到这些类型的错误。
所以你只需检查实体,存储库和服务中使用的参数类型。