附录
XML 模式
附录的这一部分列出了用于数据访问的 XML 模式,包括以下内容:
tx
模式
tx
标签用于配置 Spring 全面事务支持中的所有 bean。这些标签在 事务管理 一章中有所介绍。
我们强烈建议您查看 Spring 发布版中附带的 |
为了完整起见,要使用 tx
模式中的元素,您需要在 Spring XML 配置文件顶部添加以下序言。以下代码片段中的文本引用了正确的模式,以便 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" [id="CO1-1"]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 [id="CO1-2"]2
http://www.springframework.org/schema/aop
https://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- bean definitions here -->
</beans>
<1> 声明使用 `tx` 命名空间。 <1> 指定位置(与其他模式位置一起)。
通常,当您使用 |
jdbc
模式
要使用 jdbc
模式中的元素,您需要在 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" [id="CO2-1"]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"> [id="CO2-2"]2
<!-- bean definitions here -->
</beans>
<1> 声明使用 `jdbc` 命名空间。 <1> 指定位置(与其他模式位置一起)。