1. 程式人生 > >springboot 資料來源迴圈依賴問題 eureka服務無法被呼叫,錯誤程式碼405

springboot 資料來源迴圈依賴問題 eureka服務無法被呼叫,錯誤程式碼405

Spring
  cloud:
    refresh:
      refreshable: none

以上為解決辦法。

我在部署item-service,當時沒有新增 spring-boot-starter-actuator 依賴,導致微服務不能被檢測到,後來加了這個依賴之後,出現如下問題:

org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'scopedTarget.dataSource': Requested bean is currently in creation: Is there an unresolvable circular reference?

而且一直生成

============================
CONDITIONS EVALUATION REPORT
============================ 

***************************
APPLICATION FAILED TO START
***************************

Description:

The dependencies of some of the beans in the application context form a cycle:

   servletEndpointRegistrar defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration.class]
      ↓
   healthEndpoint defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]
      ↓
   org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthIndicatorAutoConfiguration
┌─────┐
|  dataSource
↑     ↓
|  scopedTarget.dataSource defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]
↑     ↓
|  org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker
└─────┘

用idea檢視依賴關係圖,有多處報紅線,顯示依賴有問題,所以在application.yml檔案中加入開頭的配置,就好了。