0
votes

I'm upgrading a cloud app using Oauth from spring-boot 1.5 to 2.2.4. It works locally but fails on deploying to PCF.

Below are the dependencies. My first suspicion would be version incompatiblity haven't been able to trace a conflict with these so far. Can anyone offer direction?

  • 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
1

1 Answers

0
votes

This was caused by duplicates of this library being pulled in. After removing the duplicate the issue went away.

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