We are migrating our microservice application from Spring Boot 2.7 to Spring Boot 3.2.4.
We have a library that is imported into all our microservices. In this library, there is an abstract class that defines some beans and is supposed to be implemented by all microservices. It also has some methods that allow the configuration of those beans by overriding them.
Example of library abstract class
public abstract class ConfigurationAbstractClass{
@Bean
protected ConfigurableBean configure(){
*ConfigurableBean creation code*
customConfiguration(configurableBean);
*other configuration logic*
}
protected void customConfiguration(ConfigurableBean configurableBean){
}
@Bean
public CommonBean commonBean(){
*CommonBean creation and return*
}
}
The subclasses can override the method customConfiguration in order for the ConfigurableBean to have a custom configuration in each microservice.
Example of the microservice implementation class
@Configuration
public class ConfigurationImplementationClass extends ConfigurationAbstractClass {
@Override
protected void customConfiguration(ConfigurableBean configurableBean){
*configuration code*
}
}
In Spring Boot 2.7 all the Beans are created successfully.
In Spring Boot 3.2.4 the code compiles but our tests fail with an error saying it can’t find a Bean of type CustomBean.
I’ve seen the changes regarding the migration of autoconfiguration from spring.factories but in this case I’m not sure it applies since this class was never autoconfigured.