2017-10-05 19:23:18 +08:00
|
|
|
= Appendix
|
|
|
|
|
2017-10-19 02:24:17 +08:00
|
|
|
|
|
|
|
|
2017-10-05 19:23:18 +08:00
|
|
|
[[xsd-schemas]]
|
|
|
|
== XML Schemas
|
|
|
|
|
2018-09-05 23:15:53 +08:00
|
|
|
This part of the appendix lists XML schemas for data access, including the following:
|
|
|
|
|
|
|
|
* <<xsd-schemas-tx>>
|
|
|
|
* <<xsd-schemas-jdbc>>
|
2017-10-05 19:23:18 +08:00
|
|
|
|
|
|
|
|
2017-10-19 02:24:17 +08:00
|
|
|
|
2017-10-05 19:23:18 +08:00
|
|
|
[[xsd-schemas-tx]]
|
2018-09-05 23:15:53 +08:00
|
|
|
=== The `tx` Schema
|
2017-10-05 19:23:18 +08:00
|
|
|
|
|
|
|
The `tx` tags deal with configuring all of those beans in Spring's comprehensive support
|
|
|
|
for transactions. These tags are covered in the chapter entitled
|
|
|
|
<<data-access.adoc#transaction,Transaction Management>>.
|
|
|
|
|
2018-09-05 23:15:53 +08:00
|
|
|
TIP: We strongly encourag you to look at the `'spring-tx.xsd'` file that ships with the
|
|
|
|
Spring distribution. This file contains the XML Schema for Spring's transaction
|
|
|
|
configuration and covers all of the various elements in the `tx` namespace, including
|
|
|
|
attribute defaults and similar information. This file is documented inline, and, thus, the
|
2017-10-05 19:23:18 +08:00
|
|
|
information is not repeated here in the interests of adhering to the DRY (Don't Repeat
|
|
|
|
Yourself) principle.
|
|
|
|
====
|
|
|
|
|
2018-09-05 23:15:53 +08:00
|
|
|
In the interest of completeness, to use the elements in the `tx` schema, you need to have
|
|
|
|
the following preamble at the top of your Spring XML configuration file. The text in the
|
2017-10-05 19:23:18 +08:00
|
|
|
following snippet references the correct schema so that the tags in the `tx` namespace
|
2018-09-05 23:15:53 +08:00
|
|
|
are available to you:
|
2017-10-05 19:23:18 +08:00
|
|
|
|
2018-09-05 23:15:53 +08:00
|
|
|
====
|
2017-10-05 19:23:18 +08:00
|
|
|
[source,xml,indent=0]
|
|
|
|
[subs="verbatim,quotes"]
|
|
|
|
----
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
|
|
xmlns:aop="http://www.springframework.org/schema/aop"
|
2018-09-05 23:15:53 +08:00
|
|
|
xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" <1>
|
2017-10-05 19:23:18 +08:00
|
|
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
2018-09-05 23:15:53 +08:00
|
|
|
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd <2>
|
2017-10-05 19:23:18 +08:00
|
|
|
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- bean definitions here -->
|
|
|
|
|
|
|
|
</beans>
|
|
|
|
----
|
2018-09-05 23:15:53 +08:00
|
|
|
<1> Specify the namespace.
|
|
|
|
<2> Specify the location (with other schema locations).
|
2017-10-05 19:23:18 +08:00
|
|
|
====
|
2018-09-05 23:15:53 +08:00
|
|
|
|
|
|
|
NOTE: Often, when you use the elements in the `tx` namespace, you are also using the elements from the
|
2017-10-05 19:23:18 +08:00
|
|
|
`aop` namespace (since the declarative transaction support in Spring is implemented
|
2018-09-05 23:15:53 +08:00
|
|
|
by using AOP). The preceding XML snippet contains the relevant lines needed to reference the
|
|
|
|
`aop` schema so that the elements in the `aop` namespace are available to you.
|
2017-10-05 19:23:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[[xsd-schemas-jdbc]]
|
2018-09-05 23:15:53 +08:00
|
|
|
=== The `jdbc` Schema
|
2017-10-05 19:23:18 +08:00
|
|
|
|
2018-09-05 23:15:53 +08:00
|
|
|
The `jdbc` elements let you quickly configure an embedded database or initialize an
|
|
|
|
existing data source. These elements are documented in
|
|
|
|
<<data-access.adoc#jdbc-embedded-database-support,Embedded Database Support>>
|
|
|
|
and <<data-access.adoc#jdbc-initializing-datasource,Initializing a DataSource>>, respectively.
|
2017-10-05 19:23:18 +08:00
|
|
|
|
2018-09-05 23:15:53 +08:00
|
|
|
To use the elements in the `jdbc` schema, you need to have the following preamble at the top
|
|
|
|
of your Spring XML configuration file. The text in the following snippet references the
|
|
|
|
correct schema so that the elements in the `jdbc` namespace are available to you:
|
2017-10-05 19:23:18 +08:00
|
|
|
|
2018-09-05 23:15:53 +08:00
|
|
|
====
|
2017-10-05 19:23:18 +08:00
|
|
|
[source,xml,indent=0]
|
|
|
|
[subs="verbatim,quotes"]
|
|
|
|
----
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
2018-09-05 23:15:53 +08:00
|
|
|
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xsi:schemaLocation=" <2>
|
2017-10-05 19:23:18 +08:00
|
|
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
2018-09-05 23:15:53 +08:00
|
|
|
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd"> <!-- bean definitions here --> <2>
|
2017-10-05 19:23:18 +08:00
|
|
|
|
|
|
|
</beans>
|
|
|
|
----
|
2018-09-05 23:15:53 +08:00
|
|
|
<1> Specify the namespace.
|
|
|
|
<2> Specify the location (with other schema locations).
|
|
|
|
====
|