Когда я пытаюсь добавить Oauth2.0 Client в мое приложение SpringBoot, я получаю следующую ошибку:
Parameter 0 of method tokenRelayGatewayFilterFactory in org.springframework.cloud.security.oauth2.gateway.TokenRelayAutoConfiguration required a bean of type 'org.springframework.security.oauth2.client.web.server.ServerOAuth2AuthorizedClientRepository' that could not be found.
The following candidates were found but could not be injected:
- Bean method 'authorizedClientRepository' in 'ReactiveOAuth2ClientAutoConfiguration' not loaded because @ConditionalOnBean (types: org.springframework.security.oauth2.client.ReactiveOAuth2AuthorizedClientService; SearchStrategy: all) did not find any beans of type org.springframework.security.oauth2.client.ReactiveOAuth2AuthorizedClientService
Action:
Consider revisiting the entries above or defining a bean of type 'org.springframework.security.oauth2.client.web.server.ServerOAuth2AuthorizedClientRepository' In your configuration.
Вот как я делаю конфигурацию для добавления Oauth 2.0 в мое Spring Boot Application.
Я добавляю эти зависимости в мой pom. xml
pom. xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
В файл application.yaml
routes:
- id: securedApp
uri: http://localhost:8981
predicates:
- Path=/securedApp/**
filters:
- TokenRelay=