最近在做授權、認證,引入了,在啓動項目的時候總是在報錯,數據源循環依賴問題。
SpringBoot 版本: 2.0.1.RELEASE
Spring Cluoud 版本:Finchley.SR1
使用的是:spring-cloud-starter-oauth2
錯誤提示:
***************************
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
└─────┘
最後經過驗證,是版本問題,經過查詢,SpringBoot 2.0有這個問題,在2.1之後就解決了這個問題
最後引入了版本:
SpringBoot 版本: 2.1.4.RELEASE
Spring Cluoud 版本:Greenwich.RELEASE
成功解決了數據源循環依賴的問題。