Our Java / Spring boot application is using a library. The library has a class defined as below:
@Configuration
public class Test {
public Test() {
}
@Autowired
@Bean
SomeBean someBean(A a) {
return new SomeBean("s");
}
}
The application triggers the following error during startup.
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: @Bean method 'someBean' must not be declared as autowired; remove the method-level @Autowired annotation.
Offending resource: class path resource [com/example/demo/Test.class]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:72) ~[spring-beans-6.2.2.jar:6.2.2]
Spring-beans version 6.1.4, does not result in this error. Most probably, this validation came-in in one of the subsequent spring beans versions. Our application is using spring-beans 6.2.2.
I know that the @Autowired annotation is unnecessary. The error message is clear. The removal of @Autowired annotation would fix the issue. Unfortunately, the class exists in a library (within a jar)
So the question is: How to fix this error when the configuration class "Test" exists in a library (jar) ?