[BUG] Circular references about restTemplateBuilder
See original GitHub issueDescribe the bug A Spring Boot 2.7.4 application having dependencies on both spring-boot-starter-data-rest and spring-cloud-azure-starter-active-directory 4.4.0 fails to start due to circular references. Using spring-cloud-azure-starter-active-directory 4.3.0 works fine.
Exception or Stack Trace
***************************
APPLICATION FAILED TO START
***************************
Description:
The dependencies of some of the beans in the application context form a cycle:
com.azure.spring.cloud.autoconfigure.aad.AadAuthenticationFilterAutoConfiguration
┌─────┐
| restTemplateBuilder defined in class path resource [org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfiguration.class]
↑ ↓
| restTemplateBuilderConfigurer defined in class path resource [org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfiguration.class]
↑ ↓
| messageConverters defined in class path resource [org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.class]
↑ ↓
| jacksonHttpMessageConverter defined in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]
↑ ↓
| linkCollector defined in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]
↑ ↓
| selfLinkProvider defined in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]
↑ ↓
| org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration
↑ ↓
| org.springframework.security.config.annotation.web.configuration.OAuth2ClientConfiguration$OAuth2ClientWebMvcSecurityConfiguration
↑ ↓
| com.azure.spring.cloud.autoconfigure.aad.configuration.AadOAuth2ClientConfiguration
└─────┘
Action:
Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.
To Reproduce Create a new Spring Boot project at https://start.spring.io/ and select the following dependencies:
- Rest Repositories
- Azure Active Directory
- Spring Security
- OAuth2 Client
Then enable AAD in the application.yaml file:
spring:
cloud:
azure:
active-directory:
enabled: true
credential:
client-id: whatever
client-secret: whatever
profile:
tenant-id: whatever
user-group:
allowed-group-names: whatever
Code Snippet N/A
Expected behavior The Spring Boot application starts (and immediately terminates because it’s not a web application) without error.
Screenshots N/A
Setup (please complete the following information):
- OS: Windows
- IDE: IntelliJ
- Library/Libraries:
- org.springframework.boot:spring-boot-starter-data-rest:2.7.4
- org.springframework.boot:spring-boot-starter-oauth2-client:2.7.4
- org.springframework.boot:spring-boot-starter-security:2.7.4
- com.azure.spring:spring-cloud-azure-starter-active-directory:4.4.0
- Java version: 11
- App Server/Environment: N/A
- Frameworks: Spring Boot 2.7.4
Additional context This could be related to https://github.com/Azure/azure-sdk-for-java/pull/31048 Downgrading to com.azure.spring:spring-cloud-azure-starter-active-directory:4.3.0 solves the problem. Removing the org.springframework.boot:spring-boot-starter-data-rest dependency also “solves” the problem.
Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- Bug Description Added
- Repro Steps Added
- Setup information Added
Issue Analytics
- State:
- Created a year ago
- Comments:8 (6 by maintainers)
Top GitHub Comments
Hi, @sigiswald, thanks for reaching out. I’ll investigate this issue and give feedback ASAP.
@saragluna could you please take a look at this issue, thanks.