附录
XML 模式
附录的这一部分列出了用于数据访问的 XML 模式,包括以下内容:
这tx
图式
这tx
标签处理在 Spring 的全面支持中配置所有这些 bean
用于交易。这些标记在标题为“事务管理”的章节中进行了介绍。
我们强烈建议您查看'spring-tx.xsd' 文件附带的
春季分配。此文件包含 Spring 事务的 XML Schema
配置,并涵盖了tx 命名空间,包括
属性默认值和类似信息。此文件是内联记录的,因此,
为了遵守 DRY(不要
重复自己)原则。 |
为了完整起见,使用tx
schema,你需要有
Spring XML 配置文件顶部的以下前导码。中的文本
以下代码段引用正确的架构,以便tx
Namespace
可供您:
<?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 | 声明tx Namespace。 |
2 | 指定位置(与其他架构位置)。 |
通常,当您使用tx 命名空间,您还在使用
元素来自aop 命名空间(因为 Spring 中的声明式事务支持
使用 AOP 实现)。前面的 XML 代码片段包含所需的相关行
引用aop schema,以便aop 命名空间可用
给你。 |
这jdbc
图式
要使用jdbc
schema,您需要在
Spring XML 配置文件的顶部。以下代码片段中的文本引用
正确的架构,以便jdbc
命名空间可供您使用:
<?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 | 声明jdbc Namespace。 |
2 | 指定位置(与其他架构位置)。 |