This repository was archived by the owner on May 31, 2022. It is now read-only.

Description
This was originally raised against Spring Boot, but the underlying problem is in Spring Security OAuth. Please see this Spring Boot issue for the details.
The summary is that multiple beans that implement ResourceServerTokenServices are registered with the application context. Depending on what other calls are made to the bean factory, one or both of those beans may be found. When both are found, neither is primary and a NoUniqueBeanDefinitionException is thrown.
This is the simplest reproduction that I'm aware of:
package com.example;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices;
@EnableAuthorizationServer
@EnableWebSecurity
public class BrokenOAuthApplication extends AuthorizationServerConfigurerAdapter {
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(BrokenOAuthApplication.class);
context.getBean(ResourceServerTokenServices.class);
context.close();
}
}
This fails with Security OAuth 2.0.12.RELEASE, Security 4.2.1.RELEASE, and Framework 4.3.5.RELEASE.