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
...全文
5627 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
木心__ 2018-10-22
  • 打赏
  • 举报
回复
问题已解决,因为xml配置没有打到jar包里,并且新项目没有引用xml文件,所以找到不到对应的bean
木心__ 2018-10-22
  • 打赏
  • 举报
回复
有没有大神帮忙看下~~~谢谢!!

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧