Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document @Bean definitions via default methods #767

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/asciidoc/core-beans.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5922,6 +5922,25 @@ Both declarations make a bean named `transferService` available in the
transferService -> com.acme.TransferServiceImpl
----

You can also use Java 8 default methods to define beans. This allows composition
of bean configurations by implementing interfaces with bean definitions on default methods.

[source,java,indent=0]
[subs="verbatim,quotes"]
----
public interface FooConfig {
@Bean
default Foo foo() {
Foo foo = new Foo();
foo.init();
return foo;
}
}

@Configuration
public class AppConfig implements FooConfig {
}
----

[[beans-java-dependencies]]
==== Bean dependencies
Expand Down