Closed
Description
Marty Pitt opened SPR-11740 and commented
Currently, when declaring my beans via Java config, I'm provided with two options:
- Implicitly, without construction responsibility -- Using a
@Component
annotation, and let Spring discover the bean. - Explicitly, with construction responsibility -- Using a
@Bean
annotation within a@Configuration
class.
There is a valid use case where I would like to explicitly declare a set of beans, but leave Spring responsible for their construction.
This is analogous to the classic <bean class="">
xml approach.
A possible syntax for this would be:
@Configuration
public class MyAppConfig {
// Explictly provide the class, not the instance to Spring
@Bean
public MyFunkySpringBean funkyBean; // No instance -- it's up to Spring to build
}
Reference URL: http://stackoverflow.com/questions/23313262/spring-java-config-specify-class-only
Issue Links:
- @Bean on Java 8 default methods in interfaces [SPR-10919] #15547
@Bean
on Java 8 default methods in interfaces
Referenced from: commits f0ac278, a15dc08
1 votes, 9 watchers