1. 程式人生 > 其它 >關於A component required a bean of type ‘com.xx.ProductClient‘ that could not be found解決方案

關於A component required a bean of type ‘com.xx.ProductClient‘ that could not be found解決方案

技術標籤:Exception

報錯資訊

Description:
A component required a bean of type 'com.demo.user9998.client.ProductClient' that could not be found.

Action:
Consider defining a bean of type 'com.demo.user9998.client.ProductClient' in your configuration.

報錯解釋:該類沒有被注入,說明沒有被掃描到,@SpringBootApplication出現了問題,沒有掃描到該類

解決方案

1、將該類放在同使用這個類的同級目錄,或者子目錄

2、將該類原本的包單獨掃描,在啟動類上面添加註解

@ComponentScan(basePackages = {"com.demo.user9998.client"} )

在這裡插入圖片描述
詳情參考該博主:https://blog.csdn.net/wolfking0608/article/details/82863442