mutiple scopedTarget.oauth2ClientContext bean in resource server
KevinQian opened this issue · 3 comments
when I integrate spring cloud security with zuul, I found that it couldn't start. Error as below:
The bean 'scopedTarget.oauth2ClientContext', defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2RestOperationsConfiguration$SessionScopedConfiguration$ClientContextConfiguration.class], could not be registered. A bean with that name has already been defined in org.springframework.security.oauth2.config.annotation.web.configuration.OAuth2ClientConfiguration$OAuth2ClientContextConfiguration and overriding is disabled.
I researched it and found that @EnableOAuth2Client imported OAuth2ClientConfiguration and created OAuth2ClientContext bean. However OAuth2AutoConfiguration also imported OAuth2RestOperationsConfiguration which also created OAuth2ClientContext.
Because OAuth2RestOperationsConfiguration has annotation @ConditionalOnClass(EnableOAuth2Client.class), I suggest whether we could add @ConditionalOnMissing annotation when creating OAuth2ClientContext bean?
@KevinQian I am also having the same error in my App. Could you please tell me what changes you did to your code to resolve the error?
@KevinQian I am also having the same error in my App. Could you please tell me what changes you did to your code to resolve the error?
@Bsmalhi add spring: main: allow-bean-definition-overriding: true
config
to allow overriding bean definition
None of these projects are hosted here. Please file an issue in the appropriate repo.