Skip to content

Commit

Permalink
Merge pull request #767 from thomasdarimont
Browse files Browse the repository at this point in the history
* pr/767:
  Document @bean definitions via default methods

Closes gh-767
  • Loading branch information
snicoll committed Nov 22, 2021
2 parents 3290495 + 767299c commit 8e8c88e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/docs/asciidoc/core/core-beans.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7953,6 +7953,26 @@ following text image shows:
transferService -> com.acme.TransferServiceImpl
----

You can also use 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",role="primary"]
.Java
----
public interface BaseConfig {
@Bean
default TransferServiceImpl transferService() {
return new TransferServiceImpl();
}
}
@Configuration
public class AppConfig implements BaseConfig {
}
----

You can also declare your `@Bean` method with an interface (or base class)
return type, as the following example shows:

Expand Down

0 comments on commit 8e8c88e

Please sign in to comment.