Closed
Description
Describe the bug
I am getting a warning that I should annotate a particular class with @Configuration
, as the class defines some @Bean
methods. The class in question is a Feign configuration class. I apply this class selectively to specific feign clients. If I add the annotation as suggested the class becomes "global" applying to all feign clients.
Interestingly, if I remove the @Bean
annotation the RequestInterceptor
will not be applied by Feign despite being explicitly set on the FeignClient, so I see 3 possibilities here:
- the vscode extention is being overzealous in its warning, or
- the Feign request interceptor is abusing the use of
@Bean
and should not require that annotation when the config is explicitly applied, or - I am just doing something silly... highly likely
To Reproduce
Define a class like so:
public class AdminBearerAuthFeignConfig {
@Bean
public RequestInterceptor someInterceptor() {
return requestTemplate -> {
requestTemplate.header(
"Hello",
"World"
);
};
}
}
This should yield a warning like:
[{
"resource": "/whatever/SomeClass.java",
"owner": "_generated_diagnostic_collection_name_#3",
"code": "MISSING_CONFIGURATION_ANNOTATION",
"severity": 4,
"message": "'@Configuration' is missing on a class defining Spring Beans",
"source": "vscode-spring-boot",
"startLineNumber": 18,
"startColumn": 14,
"endLineNumber": 18,
"endColumn": 40
}]
Sample
Will provide one later, got to get on with the day job.