I am using Spring Cloud Angel.SR4. My Configuration class for creating an OAuth2RestTemplate
bean is as follows:
@Configuration
public class OAuthClientConfiguration {
@Autowired
private MyClientCredentialsResourceDetails resource;
public OAuthClientConfiguration() {
}
@Bean
@Qualifier("MyOAuthRestTemplate")
public OAuth2RestTemplate restTemplate() {
return new OAuth2RestTemplate(this.resource);
}
}
This configuration is totally fine since I am using this RestTemplate
in a Feign RequestInterceptor
for injecting access tokens to the feign requests. The problem is that when I annotate an autowired OAuth2RestTemplate
with @LoadBalanced
the dependency injection engine raises a NoSuchBeanDefinitionException
exception. For example, the following would raise an exception:
@LoadBalanced
@Autowired
@Qualifier("MyOAuthRestTemplate")
private OAuth2RestTemplate restTemplate;
and when I remove the @LoadBalanced
, everything works fine. What is wrong with @LoadBalanced
? Do I need any additional configurations (I already have @EnableEurekaClient
)?