spring - 一堆更改后如何解决 UnsatisfiedDependencyException
问题描述
嗨,我是 Spring 世界的新手,需要一些想法来解决这个问题。在我更新了一堆文件后,Spring Web 服务无法成功启动。
TestMainApplication
是我的主要引导文件。
我相信根本原因来自chartServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 6;
但是,我还没有从secondaryChannelServiceImpl
.
有什么想法或方向来研究这类问题吗?
构造函数重复问题还是?
at com.iicloud.goodOrg.TestMain.service.TestMainApplication.main(TestMainApplication.java:69)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration': Unsatisfied dependency
expressed through method 'setConfigurers' parameter 0;
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'TestMainApplication':
Unsatisfied dependency expressed through field 'chartService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'chartServiceImpl' defined in file [.../charts/service/impl/chartServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 6; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'secondaryChannelServiceImpl'
解决方案
UnsatisfiedDependencyException 可能由于多种原因而发生。
如果我们没有为特定类创建 bean,或者我们错过了该类的 @Component 注释。Spring 不会管理这些类,因此 Spring 容器不会创建要自动装配的对象。
不属于组件扫描的包的自动装配类。Spring 将仅在包扫描中包含的包中搜索组件。
如果存在非唯一的依赖解决方案。如果一个接口有两个以上的实现,Spring 将不知道要自动装配哪一个。这可以通过使用@Qualifier 注释和@Autowired 提及正确的实现来避免。
推荐阅读
- milliseconds - 如何获得两个 QDateTimes 之间的区别?
- python - python对pandas.core.frame.Dataframe的索引不正确/如何删除csv文件每行末尾的逗号?
- html - 如何在 Odoo 13 中设置 invoice_payment_term_id 所需的?
- javascript - 运行 React Native 应用程序时出错 - 未知选项
- html - 标头中 div 之间的徽标位置
- c# - 如何在c#中获取没有子目录的目录
- gtk3 - 为什么在调整整个窗口大小之前我的 GtkBox 不会更新?
- macos - macOS - 获取当前正在运行的应用程序的路径
- bash - 将我的 git bash 凭据从虚拟机切换到我的家庭系统
- python - Python numpy/matplotlib 轴/函数缩放