refresh刷新容器时提示Autowired无法注入

Inory丶snow 2019-07-27 11:44:29
项目正常启动没有问题
这是@Configuration下RabbitMQConfig

这是通过接口调用ac.refresh();

这是运行结果


到这里都是没有任何问题的,项目启动时RabbitMQConfig初始化正常,通过接口调用ac.refresh(),刷新容器重新初始化RabbitMQConfig正常

但是如果我在RabbitMQConfig使用@Autowired注入,项目启动时可以正常运行,但是调用ac.refresh()则会出错,提示无法注入
这是@Configuration下RabbitMQConfig

这是通过接口调用ac.refresh();

这是运行结果


发出告警
2019-07-27 11:40:36.521 WARN 7444 --- [nio-8120-exec-1] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rabbitMqConfig': Unsatisfied dependency expressed through field 'demoConfigurationService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'demoConfigurationService': Unsatisfied dependency expressed through field 'dao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.pubinfo.modules.demo.dao.DemoConfigurationDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2019-07-27 11:40:36.586 WARN 7444 --- [nio-8120-exec-1] .m.m.a.ExceptionHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rabbitMqConfig': Unsatisfied dependency expressed through field 'demoConfigurationService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'demoConfigurationService': Unsatisfied dependency expressed through field 'dao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.pubinfo.modules.demo.dao.DemoConfigurationDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

...全文
81 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Inory丶snow 2019-07-27
  • 打赏
  • 举报
回复
顶一波,请各位看看啊

50,534

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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