Consistent @Bean method return type for equivalence with XML example #29338
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: documentation
A documentation task
Milestone
Via @maciejwalkowiak and spring-projects/spring-boot#32763, I think Framework's reference documentation on
@Bean
methods and the return type in their method signature could be clarified. The documentation contains the following Java config and XML examples:The Java config example is depriving the bean factory of some type information. It will only know that the
myService
bean is aMyServiceImpl
once the bean has been created. This can have an impact on injection points that consume aMyServiceImpl
as injection will fail if it's attempted beforemyService
has been created.The XML sample is described as being equivalent to the Java config example. Strictly speaking, I don't think that's accurate. In the XML case, the bean factory will know that the bean is a
MyServiceImpl
from the outset and injection of aMyServiceImpl
will succeed irrespective of bean creation ordering.The text was updated successfully, but these errors were encountered: