The dependencies of some of the beans in the application context form a cycle:
demoController (field private com.example.gateway.feign.client.DemoFeignClient com.example.gateway.web.DemoController.demoFeignClient)
┌─────┐
| com.example.gateway.feign.client.DemoFeignClient
↑ ↓
| org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration$EnableWebFluxConfiguration
↑ ↓
| org.springframework.security.config.annotation.web.reactive.ServerHttpSecurityConfiguration (field private org.springframework.security.core.userdetails.ReactiveUserDetailsService org.springframework.security.config.annotation.web.reactive.ServerHttpSecurityConfiguration.reactiveUserDetailsService)
↑ ↓
| demoUserDetailsService (field private com.example.gateway.feign.client.DemoFeignClient com.example.gateway.security.config.DemoUserDetailsService.demoFeignClient)
↑ ↓
| resourceUrlProvider
└─────┘
Don't know wether this is caused by Feign or Spring Security, spent hours can't resolve it. I create a repo reproduce this issue.
Comment From: spencergibb
You are referencing a feign client from a class that is used by spring security.
public class DemoUserDetailsService implements ReactiveUserDetailsService {
@Autowired
private DemoFeignClient demoFeignClient;
@Override
public Mono<UserDetails> findByUsername(String username) {
return Mono.just(new User("hello", "pass", null));
}
}
That is what is causing the cycle. Try injecting ObjectProvider<DemoFeignClient>.
Comment From: zjengjie
I modify the SecurityConfiguration to
@EnableWebFluxSecurity
public class SecurityConfiguration {
@Bean
public DemoUserDetailsService demoUserDetailsService(ObjectProvider<DemoFeignClient> demoFeignClientObjectProvider) {
return new DemoUserDetailsService(demoFeignClientObjectProvider.getIfAvailable());
}
}
It still didn't work, don't understand why feignclient will dependent on spring security, if remove the @Bean method and add a @Component annotation on DemoUserDetailsService, the demo project worked fine, but don't work on my origin project.
This happened on I upgrade spring boot version from 2.0.4.RELEASE to 2.1.3.RELEASE, sprint cloud version from Finchley.RELEASE to Greenwich.RELEASE.
And I test when use spring boot 2.0.6.RELEASE and spring cloud Finchley.RELEASE will be fine, change to spring boot 2.0.7.RELEASE will throw this error, but openfeign's version didn't change, maybe it's a bug of spring?
Comment From: ryanjbaxter
Yes if the Spring Cloud version did not change then it seems to not be a bug in Spring Cloud.
Comment From: ghost
Getting same error after updating the version `***** APPLICATION FAILED TO START
Description:
The dependencies of some of the beans in the application context form a cycle:
┌─────┐ | gatewayAuthenticationManager defined in file [/home/nitin/projects/cloud-gateway-web/build/classes/java/main/com/example/gateway/auth/GatewayAuthenticationManager.class] ↑ ↓ | com.example.client.AuthenticationClient ↑ ↓ | org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration$EnableWebFluxConfiguration ↑ ↓ | org.springframework.security.config.annotation.web.reactive.ServerHttpSecurityConfiguration (field private org.springframework.security.authentication.ReactiveAuthenticationManager org.springframework.security.config.annotation.web.reactive.ServerHttpSecurityConfiguration.authenticationManager) └─────┘
`
Comment From: crab890715
@zjengjie 你是怎么修复的这个问题
Comment From: nitin-vavdiya
你是怎么修复的这个问题
I replace feign client with WebClient
Comment From: alonelaval
lol,我也碰到这个问题了。