Closed
Description
Consider the following use case:
@Configuration
public class Config {
@Bean(name = "myBean")
MyBean someBean() { ... }
@Bean(name = "myBean")
MyBean someBean(MyDependency) { ... }
}
The container accepts an override for myBean
as long as it is in the same configuration class to mimic the resolution of the greediest satisfiable constructors for bean factory methods.
Such an arrangement is much better served using Optional
or ObjectProvider
with a single bean factory method as it makes it explicit that some argument may or may not be available.