@@ -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
TIP: If you want to influence the startup creation order of certain beans, consider
507
508
declaring some of them as `@Lazy` (for creation on first access instead of on startup)
@@ -594,8 +595,10 @@ that uses Spring XML, it is easier to create `@Configuration` classes on an
594
595
as-needed basis and include them from the existing XML files. Later in this section, we cover the
595
596
options for using `@Configuration` classes in this kind of "`XML-centric`" situation.
596
597
597
- .[[beans-java-combining-xml-centric-declare-as-bean]]Declaring `@Configuration` classes as plain Spring `<bean/>` elements
598
- --
598
+ [discrete]
599
+ [[beans-java-combining-xml-centric-declare-as-bean]]
600
+ ==== Declaring `@Configuration` classes as plain Spring `<bean/>` elements
601
+
599
602
Remember that `@Configuration` classes are ultimately bean definitions in the
600
603
container. In this series examples, we create a `@Configuration` class named `AppConfig` and
601
604
include it within `system-test-config.xml` as a `<bean/>` definition. Because
@@ -703,16 +706,16 @@ Kotlin::
703
706
----
704
707
======
705
708
706
-
707
709
NOTE: In `system-test-config.xml` file, the `AppConfig` `<bean/>` does not declare an `id`
708
710
element. While it would be acceptable to do so, it is unnecessary, given that no other bean
709
711
ever refers to it, and it is unlikely to be explicitly fetched from the container by name.
710
712
Similarly, the `DataSource` bean is only ever autowired by type, so an explicit bean `id`
711
713
is not strictly required.
712
- --
713
714
714
- .[[beans-java-combining-xml-centric-component-scan]] Using <context:component-scan/> to pick up `@Configuration` classes
715
- --
715
+ [discrete]
716
+ [[beans-java-combining-xml-centric-component-scan]]
717
+ ==== Using <context:component-scan/> to pick up `@Configuration` classes
718
+
716
719
Because `@Configuration` is meta-annotated with `@Component`, `@Configuration`-annotated
717
720
classes are automatically candidates for component scanning. Using the same scenario as
718
721
described in the previous example, we can redefine `system-test-config.xml` to take advantage of component-scanning.
@@ -736,7 +739,6 @@ The following example shows the modified `system-test-config.xml` file:
736
739
</bean>
737
740
</beans>
738
741
----
739
- --
740
742
741
743
[[beans-java-combining-java-centric]]
742
744
=== `@Configuration` Class-centric Use of XML with `@ImportResource`
0 commit comments