File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -5419,11 +5419,18 @@ factory methods as you see fit in non-`@Configuration` classes and also for stat
54195419methods anywhere. However, regular `@Bean` methods in `@Configuration` classes need
54205420to be overridable, i.e. they must not be declared as `private` or `final`.
54215421
5422- Finally, `@Bean` methods will also be discovered on base classes of a given component
5423- or configuration class, as well as on Java 8 default methods declared in interfaces
5422+ `@Bean` methods will also be discovered on base classes of a given component or
5423+ configuration class, as well as on Java 8 default methods declared in interfaces
54245424implemented by the component or configuration class. This allows for a lot of
54255425flexibility in composing complex configuration arrangements, with even multiple
54265426inheritance being possible through Java 8 default methods as of Spring 4.2.
5427+
5428+ Finally, note that a single class may hold multiple `@Bean` methods for the same
5429+ bean, as an arrangement of multiple factory methods to use depending on available
5430+ dependencies at runtime. This is the same algorithm as for choosing the "greediest"
5431+ constructor or factory method in other configuration scenarios: The variant with
5432+ the largest number of satisfiable dependencies will be picked at construction time,
5433+ analogous to how the container selects between multiple `@Autowired` constructors.
54275434====
54285435
54295436
You can’t perform that action at this time.
0 commit comments