对于最新的稳定版本,请使用 Spring Framework 7.0.6!spring-doc.cadn.net.cn

附录

XML模式

本附录的这一部分列出了数据访问的XML模式,包括以下内容:spring-doc.cadn.net.cn

tx架构

tx 标签处理配置 Spring 事务全面支持中的所有这些 bean。这些标签将在名为 事务管理 的章节中进行介绍。spring-doc.cadn.net.cn

我们强烈建议您查看随Spring发行版一起提供的'spring-tx.xsd'文件。该文件包含Spring事务配置的XML Schema,并涵盖了tx命名空间中的各种元素,包括属性默认值和类似信息。此文件内联进行了文档说明,因此为了遵循DRY(不要重复自己)原则,此处不再重复相关信息。

为了确保完整性,要使用 tx 模式中的元素,你需要在 Spring XML 配置文件的顶部包含以下引言。以下片段中的文本引用了正确的模式,以便您能够使用 tx 命名空间中的标签:spring-doc.cadn.net.cn

<?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 指定位置(与其他模式位置一起)。
通常,当您使用 tx 命名空间中的元素时,也在使用 aop 命名空间中的元素(因为 Spring 的声明式事务支持是通过使用 AOP 实现的)。前面的 XML 代码片段包含引用 aop 模式的相关行,以便您可以使用 aop 命名空间中的元素。

jdbc架构

jdbc 元素可让您快速配置嵌入式数据库或初始化现有数据源。这些元素分别在 嵌入式数据库支持初始化数据源 中有记录。spring-doc.cadn.net.cn

要使用 jdbc 架构中的元素,您需要在 Spring XML 配置文件的顶部包含以下前导内容。以下片段中的文本引用了正确的架构,以便您可以使用 jdbc 命名空间中的元素:spring-doc.cadn.net.cn

<?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 指定位置(与其他模式位置一起)。