@@ -116,7 +116,7 @@ the configuration model, in that references to other beans must be valid Java sy
116
116
Fortunately, solving this problem is simple. As
117
117
xref:core/beans/java/bean-annotation.adoc#beans-java-dependencies[we already discussed],
118
118
a `@Bean` method can have an arbitrary number of parameters that describe the bean
119
- dependencies. Consider the following more real-world scenario with several `@Configuration`
119
+ dependencies. Consider the following more realistic scenario with several `@Configuration`
120
120
classes, each depending on beans declared in the others:
121
121
122
122
[tabs]
@@ -331,8 +331,10 @@ TIP: Constructor injection in `@Configuration` classes is only supported as of S
331
331
Framework 4.3. Note also that there is no need to specify `@Autowired` if the target
332
332
bean defines only one constructor.
333
333
334
- .[[beans-java-injecting-imported-beans-fq]]Fully-qualifying imported beans for ease of navigation
335
- --
334
+ [discrete]
335
+ [[beans-java-injecting-imported-beans-fq]]
336
+ ==== Fully-qualifying imported beans for ease of navigation
337
+
336
338
In the preceding scenario, using `@Autowired` works well and provides the desired
337
339
modularity, but determining exactly where the autowired bean definitions are declared is
338
340
still somewhat ambiguous. For example, as a developer looking at `ServiceConfig`, how do
@@ -501,7 +503,6 @@ Now `ServiceConfig` is loosely coupled with respect to the concrete
501
503
get a type hierarchy of `RepositoryConfig` implementations. In this
502
504
way, navigating `@Configuration` classes and their dependencies becomes no different
503
505
than the usual process of navigating interface-based code.
504
- --
505
506
506
507
507
508
[[beans-java-startup]]
@@ -631,8 +632,10 @@ that uses Spring XML, it is easier to create `@Configuration` classes on an
631
632
as-needed basis and include them from the existing XML files. Later in this section, we cover the
632
633
options for using `@Configuration` classes in this kind of "`XML-centric`" situation.
633
634
634
- .[[beans-java-combining-xml-centric-declare-as-bean]]Declaring `@Configuration` classes as plain Spring `<bean/>` elements
635
- --
635
+ [discrete]
636
+ [[beans-java-combining-xml-centric-declare-as-bean]]
637
+ ==== Declaring `@Configuration` classes as plain Spring `<bean/>` elements
638
+
636
639
Remember that `@Configuration` classes are ultimately bean definitions in the
637
640
container. In this series examples, we create a `@Configuration` class named `AppConfig` and
638
641
include it within `system-test-config.xml` as a `<bean/>` definition. Because
@@ -740,16 +743,16 @@ Kotlin::
740
743
----
741
744
======
742
745
743
-
744
746
NOTE: In `system-test-config.xml` file, the `AppConfig` `<bean/>` does not declare an `id`
745
747
element. While it would be acceptable to do so, it is unnecessary, given that no other bean
746
748
ever refers to it, and it is unlikely to be explicitly fetched from the container by name.
747
749
Similarly, the `DataSource` bean is only ever autowired by type, so an explicit bean `id`
748
750
is not strictly required.
749
- --
750
751
751
- .[[beans-java-combining-xml-centric-component-scan]] Using <context:component-scan/> to pick up `@Configuration` classes
752
- --
752
+ [discrete]
753
+ [[beans-java-combining-xml-centric-component-scan]]
754
+ ==== Using <context:component-scan/> to pick up `@Configuration` classes
755
+
753
756
Because `@Configuration` is meta-annotated with `@Component`, `@Configuration`-annotated
754
757
classes are automatically candidates for component scanning. Using the same scenario as
755
758
described in the previous example, we can redefine `system-test-config.xml` to take advantage of component-scanning.
@@ -773,7 +776,6 @@ The following example shows the modified `system-test-config.xml` file:
773
776
</bean>
774
777
</beans>
775
778
----
776
- --
777
779
778
780
[[beans-java-combining-java-centric]]
779
781
=== `@Configuration` Class-centric Use of XML with `@ImportResource`
0 commit comments