20220507 8. Data Access - Appendix
前言
XML 模式(Schema)
tx 模式
tx 标签提供对 Spring 事务的全面支持。
spring-tx.xsd 文件包含用于 Spring 的事务配置的 XML 模式,并涵盖 tx 命名空间中的所有各种标签,包括属性默认值和类似信息。
引入 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:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx" 
    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 
        http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd">
    <!-- bean definitions here -->
</beans>
通常,当您使用 tx 命名空间中的标签时,您也在使用 aop 命名空间中的标签(因为 Spring 中的声明式事务支持是通过使用 AOP 实现的)。
jdbc 模式
jdbc 标签使您可以快速配置嵌入式数据库或初始化现有数据源。这些标签分别记录在 Embedded Database Support 和 Initializing a DataSource   中。
引入 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" 
    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"> 
    <!-- bean definitions here -->
</beans>
                    
                
                
            
        
浙公网安备 33010602011771号