Skip to content

Incorrect MISSING_CONFIGURATION_ANNOTATION warning in vscode #1100

Closed
@sbreakey

Description

@sbreakey

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:

  1. the vscode extention is being overzealous in its warning, or
  2. the Feign request interceptor is abusing the use of @Bean and should not require that annotation when the config is explicitly applied, or
  3. 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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions