Annotation Type Configuration
A class whose Bean methods produce beans.
The class itself is a bean too, so its own constructor and fields can be
injected before its factory methods are called. The build calls each factory
method exactly once, directly, from the entry point it generates -- so unlike
Spring there is no proxy, and one @Bean method calling another simply gets a
second object. Take the other bean as a PARAMETER instead, which is what the
build wires:
@Configuration
public class Clients {
@Bean
public Mailer mailer(@Value("${mail.host:localhost}") String host) {
return new Mailer(host);
}
@Bean
public Notifier notifier(Mailer mailer) {
return new Notifier(mailer);
}
}
-
Optional Element Summary
Optional Elements
-
Element Details
-
value
-