Spring 启动时报错 Injection of resource dependencies failed
木心__ 2018-10-22 03:11:19 spring项目,单独启动时没有问题,当把这个项目打包后,在其他项目中引用后,在启动时报错
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(ClassA)' defined in class path resource []: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method '(ClassA)' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nameA': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'CLassB' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
在中
@Bean
public ClassC nameA() {
return new ClassC ();
}
public class ClassC implements WebSocketHandler{
@Resource
CLassB xxx;
}
xml中配置
<bean id="nameB" class="ClassD" />
ClassD implements CLassB