一、背景
模块A的包是com.a.,模块B的包是com.b.
模块A引入模块B,但是B的bean找不到。
org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext (Jdk14Logger.java:87) - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘redisMsgListener’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type
二、原因
模块A的Application在com.a下,那就只能扫描这个包下的bean,引入B模块,包名不一致,所以扫描不到B下的bean
三、解决方法
方法一:将模块A的包改成与B一致
方法二:使用@ComponentScan(value=“com.b.**”)注解,制定扫描路径
————————————————
版权声明:本文为CSDN博主「小白求学进阶」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_40295575/article/details/95616201