Closed
Description
Sometimes, one wants to be able to register a bean of a given type without breaking existing code, especially in multi-module projects. Assuming that a bean is already available:
@Bean
public SomeType someTypeBean() {
return new SomeType();
}
and used as in:
@Bean
public SomeOtherType someOtherTypeBean(SomeType val) {
return new SomeOtherType(val);
}
I would like to being able to register a bean:
@Bean
@Secondary // mirrored behavior of @Primary
public SomeType someNewTypeBean() {
return new SomeType();
}
without disturbing existing code. If the someTypeBean is missing, it should fallback to someNewTypeBean, this would also allow for much smoother migrations in the case of multiple profiles.