|
对于最新稳定版本,请使用 Spring Framework 7.0.6! |
附录
XML Schema
本附录的这一部分列出了数据访问相关的 XML Schema,包括以下内容:
这tx架构
tx 标签用于配置 Spring 对事务的全面支持中所涉及的所有 Bean。这些标签在题为
事务管理 的章节中有详细说明。
我们强烈建议您查看 Spring 发行版中附带的 'spring-tx.xsd' 文件。该文件包含了 Spring 事务配置的 XML Schema,涵盖了 tx 命名空间中的所有元素,包括属性默认值等相关信息。该文件已在内部进行了详细注释,因此为了遵循 DRY(Don’t Repeat Yourself,不要重复自己)原则,此处不再重复这些信息。 |
为了内容的完整性,若要使用 tx 命名空间中的元素,您需要在 Spring XML 配置文件的顶部包含以下前导声明。以下代码片段中的文本引用了正确的 schema,从而使 tx 命名空间中的标签对您可用:
<?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 命名空间。 |
| 2 | 指定位置(与其他 schema 位置一起)。 |
通常,当你使用 tx 命名空间中的元素时,也会同时使用 aop 命名空间中的元素(因为 Spring 中的声明式事务支持是通过 AOP 实现的)。上述 XML 片段包含了引用 aop schema 所需的相关行,以便你可以使用 aop 命名空间中的元素。 |
这jdbc架构
要使用 jdbc 命名空间中的元素,您需要在 Spring XML 配置文件的顶部包含以下前导声明。以下代码片段中的文本引用了正确的 schema,以便您可以使用 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 命名空间。 |
| 2 | 指定位置(与其他 schema 位置一起)。 |