[英]unable to autowire custom spring boot library project to my application
將自定義 spring-boot 庫 jar 導入我的應用程序,並在我運行應用程序時自動裝配顯示以下錯誤
Parameter 0 of constructor in com.dilla.de.orca.addresssvc.service.TestScheduler required a bean of type 'com.dilla.de.orca.flowersvc.service.FlowerServiceImpl' that could not be found.
圖書館模塊有以下包
FlowerSvcLibApplication.java
public static void main(final String[] args) {
SpringApplication.run(FlowerSvcLibApplication.class, args);
}
我在我的應用程序中自動裝配 Flower Service 接口,以測試庫 jar 的功能
@Component
public class MyFlowerService {
private FlowerService service;
@Autowired
public MyFlowerService(final FlowerService service) {
this.service = service;
}
我收到了我之前發布的錯誤。 我做了更多的研究,一個建議是創建“自己的自動配置”,但我還是不明白。 如何創建自動配置 class 來處理自動裝配我的庫 class,以及使用我的庫的客戶端如何提供應用程序屬性值。 目前,我對實際值進行了硬編碼,例如 Web 服務 url,現在客戶端可以將其更改為測試或產品,為此我的庫模塊設置應該如何?
請檢查@ComponenetScan 並確保它具有類似“com.dilla.de.orca”的 package 路徑
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.