Appendix
XML Schemas
本附录的这一部分列出了 XML 模式以进行数据访问,包括以下内容:
This part of the appendix lists XML schemas for data access, including the following:
The tx
Schema
tx
标签用于配置 Spring 对事务的全面支持中的所有那些 bean。这些标签在题为 Transaction Management 的章节中进行了介绍。
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
Transaction Management.
我们强烈建议你查看 Spring 发行版附带的 ’spring-tx.xsd'` 文件。该文件包含 Spring 事务配置的 XML Schema,涵盖了 |
We strongly encourage 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
模式中的元素,你需要在 Spring XML 配置文件顶部拥有下列前导部分。以下代码片段中的文本引用了正确的模式,以便向你提供 tx
命名空间中的标记:
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
following snippet references the correct schema so that the tags in the tx
namespace
are available to you:
<?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:tx="http://www.springframework.org/schema/tx" 1
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
https://www.springframework.org/schema/tx/spring-tx.xsd 2
http://www.springframework.org/schema/aop
https://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- bean definitions here -->
</beans>
1 | Declare usage of the tx namespace. |
2 | Specify the location (with other schema locations). |
通常,在使用 |
Often, when you use the elements in the |
The jdbc
Schema
jdbc
元素使你能够快速配置嵌入式数据库或初始化现有数据源。这些元素分别在 Embedded Database Support 和 Initializing a DataSource 中进行了记录。
The jdbc
elements let you quickly configure an embedded database or initialize an
existing data source. These elements are documented in
Embedded Database Support and
Initializing a DataSource, respectively.
若要使用 jdbc
模式中的元素,你需要在 Spring XML 配置文件顶部拥有下列前导部分。以下代码片段中的文本引用了正确的模式,以便向你提供 jdbc
命名空间中的元素:
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:
<?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:jdbc="http://www.springframework.org/schema/jdbc" 1
xsi:schemaLocation="
http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jdbc
https://www.springframework.org/schema/jdbc/spring-jdbc.xsd"> 2
<!-- bean definitions here -->
</beans>
1 | Declare usage of the jdbc namespace. |
2 | Specify the location (with other schema locations). |