網站首頁 編程語言 正文
新建的服務提供feign調用時,調用方無法注入提供方的feign。大致的報錯信息:
no qualifying bean of type available
調用方的啟動類注解
@ComponentScan({"com.plumelog","com.admin.**"})
@SpringBootApplication
public class AdminApplication {
提供方啟動類注解
@ComponentScan({"com.plumelog","com.push.service.**"})
@EnableFeignClients(basePackages = "com.**")
@SpringBootApplication
public class PushServiceApplication {
發現調用方沒有
@EnableFeignClients(basePackages = "com.**") 注解,于是調用方加上這個注解后,報其他錯誤:
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'authentication-feign.FeignClientSpecification' could not be registered. A bean with that name has already been defined and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
大致意思是,已經存在這個bean了,是否配置?spring.main.allow-bean-definition-overriding=true
去覆蓋它,然后加上此配置后報其他的feign注入失敗。
報錯原因分析:
定位到authentication-feign,查看該服務在feign下提供了自動裝配,項目啟動時自動注入,如果調用方啟動類加上@EnableFeifnClients注解就會注入兩次bean,所以在調用方不需要@EnableFeifnClients注解。但是不配置自動裝配就要依賴@EnableFeifnClients注解,這就互相矛盾了。
@Configuration
@EnableFeignClients(basePackages = "com.authorization.client.feign")
@ComponentScan(basePackages = "com.authorization.client.feign")
public class ClientAutoConfiguration {
解決方案:在新服務的feign包下也加上自動裝配配置。
原文鏈接:https://blog.csdn.net/Json_Marz/article/details/127007277
- 上一篇:沒有了
- 下一篇:沒有了
相關推薦
- 2023-01-07 Android實現簡單的自定義ViewGroup流式布局_Android
- 2022-06-16 原生實現C#與Lua相互調用方法(Unity3D可用)_C#教程
- 2022-11-05 pytest官方文檔解讀之安裝和使用插件的方法_python
- 2022-12-04 Android性能優化死鎖監控知識點詳解_Android
- 2022-05-05 Android開發之自定義加載動畫詳解_Android
- 2022-03-29 Python順序結構語句詳解_python
- 2022-09-03 Python?groupby函數圖文詳解_python
- 2023-02-12 如何用C++求兩個數的最大公約數和最小公倍數_C 語言
- 欄目分類
-
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支