配置资源服务请求 /oauth/check_token 的负载均衡
security:
resource:
loadBalanced: true
token-info-uri: http://localhost:8762/oauth/check_token
自动配置文件
OAuth2LoadBalancerClientAutoConfiguration
@Bean
public UserInfoRestTemplateCustomizer loadBalancedUserInfoRestTemplateCustomizer(
final LoadBalancerInterceptor loadBalancerInterceptor) {
return new UserInfoRestTemplateCustomizer() {
@Override
public void customize(OAuth2RestTemplate restTemplate) {
List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>(
restTemplate.getInterceptors());
interceptors.add(loadBalancerInterceptor);
restTemplate.setInterceptors(interceptors);
}
};
}
来源:oschina
链接:https://my.oschina.net/lemos/blog/4809646