首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

No unique bean of type [.] is defined: Unsatisfied dependency of type,该怎么解决

2013-09-11 
No unique bean of type [...] is defined: Unsatisfied dependency of type11-10-13 16:49:09 (严) Stand

No unique bean of type [...] is defined: Unsatisfied dependency of type
11-10-13 16:49:09 (严) StandardContext.listenerStart : Exception sending context initialize
d event to listener instance of class org.springframework.web.context.ContextLoaderListene
r
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'av
Service': Autowiring of fields failed; nested exception is org.springframework.beans.facto
ry.BeanCreationException: Could not autowire field: private com.cares.fare.factory.FareCac
ulateFactory com.cares.av.AvServiceImpl.agentFareCaculateFactory; nested exception is org.
springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.c
ares.fare.factory.FareCaculateFactory] is defined: Unsatisfied dependency of type [interfa
ce com.cares.fare.factory.FareCaculateFactory]: expected at least 1 matching bean
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.post
ProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateB
ean(AbstractAutowireCapableBeanFactory.java:959)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateB
ean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(Abs
tractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBea
n(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBean
Factory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(De
faultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFa
ctory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFact
ory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFact
ory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSin
gletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitia
lization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplica
tionContext.java:380)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoade
r.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.
java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoader
Listener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1315)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142
)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)


at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire fie
ld: private com.cares.fare.factory.FareCaculateFactory com.cares.av.AvServiceImpl.agentFar
eCaculateFactory; nested exception is org.springframework.beans.factory.NoSuchBeanDefiniti
onException: No unique bean of type [com.cares.fare.factory.FareCaculateFactory] is define
d: Unsatisfied dependency of type [interface com.cares.fare.factory.FareCaculateFactory]: 
expected at least 1 matching bean
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$Auto
wiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:435)
at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionM
etadata.java:105)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.post
ProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:240)
... 40 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean
 of type [com.cares.fare.factory.FareCaculateFactory] is defined: Unsatisfied dependency o
f type [interface com.cares.fare.factory.FareCaculateFactory]: expected at least 1 matchin
g bean
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency
(DefaultListableBeanFactory.java:613)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$Auto
wiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:412)
... 42 more

[解决办法]
是不是FareCaculateFactory这个类在spring配置文件中没有配置正确
[解决办法]
bean id为avService没有成功创建
原因其一个属性
FareCaculateFactory agentFareCaculateFactory; 
没有注入成功
你设置的是autowire,即by type,按照类型匹配
没有定义一个类型为
com.cares.fare.factory.FareCaculateFactory的id

热点排行