Следующее работает нормально
@Configuration
@EnableCaching
@EnableOAuth2Sso
@EnableWebSecurity
@EnableOAuth2Client
@SpringBootApplication
@Import({ AppConvConfig.class, AppPropConfig.class, AppSecConfig.class })
@EnableAspectJAutoProxy(proxyTargetClass = true)
@EnableTransactionManagement(proxyTargetClass = true)
@EntityScan(basePackages = { BeanConstants.SCAN_PKG_JDBC_ENTITY })
@EnableJpaRepositories(basePackages = { BeanConstants.SCAN_PKG_JDBC_REPO })
@ComponentScan(basePackages = { BeanConstants.SCAN_PKG_SERVI, BeanConstants.SCAN_PKG_FLICK_WEB })
public class AppConfig extends WebMvcConfigurerAdapter {
..
}
Но если я добавлю @EnableAuthorizationServer
к вышеприведенному, начнем видеть следующее исключение при запуске
***************************
APPLICATION FAILED TO START
***************************
Description:
Method springSecurityFilterChain in org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration required a single bean, but 2 were found:
- remoteTokenServices: defined by method 'remoteTokenServices' in org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration$RemoteTokenServicesConfiguration$TokenInfoServicesConfiguration
- defaultAuthorizationServerTokenServices: defined by method 'defaultAuthorizationServerTokenServices' in org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration
Action:
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