Skip to content

Commit 4fa2719

Browse files
committed
Fix titles for code listings and improve wording
1 parent acf82e7 commit 4fa2719

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

framework-docs/modules/ROOT/pages/core/beans/java/composing-configuration-classes.adoc

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -599,14 +599,14 @@ options for using `@Configuration` classes in this kind of "`XML-centric`" situa
599599
[[beans-java-combining-xml-centric-declare-as-bean]]
600600
==== Declaring `@Configuration` classes as plain Spring `<bean/>` elements
601601

602-
Remember that `@Configuration` classes are ultimately bean definitions in the
603-
container. In this series examples, we create a `@Configuration` class named `AppConfig` and
602+
Remember that `@Configuration` classes are ultimately bean definitions in the container.
603+
In this series of examples, we create a `@Configuration` class named `AppConfig` and
604604
include it within `system-test-config.xml` as a `<bean/>` definition. Because
605605
`<context:annotation-config/>` is switched on, the container recognizes the
606606
`@Configuration` annotation and processes the `@Bean` methods declared in `AppConfig`
607607
properly.
608608

609-
The following example shows an ordinary configuration class in Java:
609+
The following example shows the `AppConfig` configuration class in Java and Kotlin:
610610

611611
[tabs]
612612
======
@@ -660,6 +660,7 @@ The following example shows part of a sample `system-test-config.xml` file:
660660
<beans>
661661
<!-- enable processing of annotations such as @Autowired and @Configuration -->
662662
<context:annotation-config/>
663+
663664
<context:property-placeholder location="classpath:/com/acme/jdbc.properties"/>
664665
665666
<bean class="com.acme.AppConfig"/>
@@ -706,8 +707,8 @@ Kotlin::
706707
----
707708
======
708709

709-
NOTE: In `system-test-config.xml` file, the `AppConfig` `<bean/>` does not declare an `id`
710-
element. While it would be acceptable to do so, it is unnecessary, given that no other bean
710+
NOTE: In the `system-test-config.xml` file, the `AppConfig` `<bean/>` does not declare an `id`
711+
attribute. While it would be acceptable to do so, it is unnecessary, given that no other bean
711712
ever refers to it, and it is unlikely to be explicitly fetched from the container by name.
712713
Similarly, the `DataSource` bean is only ever autowired by type, so an explicit bean `id`
713714
is not strictly required.
@@ -718,8 +719,8 @@ is not strictly required.
718719

719720
Because `@Configuration` is meta-annotated with `@Component`, `@Configuration`-annotated
720721
classes are automatically candidates for component scanning. Using the same scenario as
721-
described in the previous example, we can redefine `system-test-config.xml` to take advantage of component-scanning.
722-
Note that, in this case, we need not explicitly declare
722+
described in the previous example, we can redefine `system-test-config.xml` to take
723+
advantage of component-scanning. Note that, in this case, we need not explicitly declare
723724
`<context:annotation-config/>`, because `<context:component-scan/>` enables the same
724725
functionality.
725726

@@ -730,6 +731,7 @@ The following example shows the modified `system-test-config.xml` file:
730731
<beans>
731732
<!-- picks up and registers AppConfig as a bean definition -->
732733
<context:component-scan base-package="com.acme"/>
734+
733735
<context:property-placeholder location="classpath:/com/acme/jdbc.properties"/>
734736
735737
<bean class="org.springframework.jdbc.datasource.DriverManagerDataSource">
@@ -744,13 +746,12 @@ The following example shows the modified `system-test-config.xml` file:
744746
=== `@Configuration` Class-centric Use of XML with `@ImportResource`
745747

746748
In applications where `@Configuration` classes are the primary mechanism for configuring
747-
the container, it is still likely necessary to use at least some XML. In these
748-
scenarios, you can use `@ImportResource` and define only as much XML as you need. Doing
749-
so achieves a "`Java-centric`" approach to configuring the container and keeps XML to a
750-
bare minimum. The following example (which includes a configuration class, an XML file
751-
that defines a bean, a properties file, and the `main` class) shows how to use
752-
the `@ImportResource` annotation to achieve "`Java-centric`" configuration that uses XML
753-
as needed:
749+
the container, it may still be necessary to use at least some XML. In such scenarios, you
750+
can use `@ImportResource` and define only as much XML as you need. Doing so achieves a
751+
"`Java-centric`" approach to configuring the container and keeps XML to a bare minimum.
752+
The following example (which includes a configuration class, an XML file that defines a
753+
bean, a properties file, and the `main()` method) shows how to use the `@ImportResource`
754+
annotation to achieve "`Java-centric`" configuration that uses XML as needed:
754755

755756
[tabs]
756757
======
@@ -803,17 +804,17 @@ Kotlin::
803804
----
804805
======
805806

807+
.properties-config.xml
806808
[source,xml,indent=0,subs="verbatim,quotes"]
807809
----
808-
properties-config.xml
809810
<beans>
810811
<context:property-placeholder location="classpath:/com/acme/jdbc.properties"/>
811812
</beans>
812813
----
813814

815+
.jdbc.properties
814816
[literal,subs="verbatim,quotes"]
815817
----
816-
jdbc.properties
817818
jdbc.url=jdbc:hsqldb:hsql://localhost/xdb
818819
jdbc.username=sa
819820
jdbc.password=
@@ -846,5 +847,3 @@ Kotlin::
846847
----
847848
======
848849

849-
850-

0 commit comments

Comments
 (0)