【问题标题】:userInfoRestTemplateFactory in ResourceServerTokenServicesConfiguration required a single bean, but 4 were foundResourceServerTokenServicesConfiguration 中的 userInfoRestTemplateFactory 需要单个 bean,但找到了 4 个
【发布时间】:2020-07-17 17:52:34
【问题描述】:

我正在将使用 Oauth 的云应用从 spring-boot 1.5 升级到 2.2.4。它在本地工作,但在部署到 PCF 时失败。

以下是依赖项。我的第一个怀疑是版本不兼容到目前为止还无法追踪与这些的冲突。谁能提供方向?

  • org.springframework.cloud:spring-cloud-starter-oauth2:jar:2.2.0.RELEASE
  • org.springframework.security.oauth:spring-security-oauth2:jar:2.4.0.RELEASE
  • org.springframework.boot:spring-boot-starter-oauth2-resource-server:jar:2.2.4.RELEASE
  • org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:jar:2.1.2.RELEASE
  • org.springframework.security:spring-security-openid:jar:5.2.1.RELEASE
  • io.pivotal.spring.cloud:spring-cloud-services-starter-config-client:jar:2.2.0.RELEASE
Method userInfoRestTemplateFactory in org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration required a single bean, but 4 were found:
2020-07-15T22:47:01.911-05:00 [APP/PROC/WEB/0] [OUT] - clientCredentialsAuthResource: defined by method 'clientCredentialsAuthResource' in class path resource ...
2020-07-15T22:47:01.911-05:00 [APP/PROC/WEB/0] [OUT] - openIdClientConfig: defined by method 'openIdClientConfig' in class path resource ...
2020-07-15T22:47:01.911-05:00 [APP/PROC/WEB/0] [OUT] - eurekaOAuth2ResourceDetails: defined by method 'eurekaOAuth2ResourceDetails' in class path resource [io/pivotal/spring/cloud/service/eureka/EurekaOAuth2AutoConfiguration.class]
2020-07-15T22:47:01.911-05:00 [APP/PROC/WEB/0] [OUT] - spring.cloud.config.client.oauth2-io.pivotal.spring.cloud.service.config.ConfigClientOAuth2ResourceDetails: defined in null
2020-07-15T22:47:01.911-05:00 [APP/PROC/WEB/0] [OUT] Action:
2020-07-15T22:47:01.911-05:00 [APP/PROC/WEB/0] [OUT] Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

【问题讨论】:

    标签: spring-boot spring-security oauth-2.0


    【解决方案1】:

    这是由于该库的副本被拉入。删除副本后问题就消失了。

    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-oauth2-resource-server</artifactId>
    </dependency> 
    

    【讨论】:

      猜你喜欢
      • 2023-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多