您好,登錄后才能下訂單哦!
一、spring命名空間
Spring中所有的命名空間:
下載Spring源文件,解壓后會有個schema目錄,里面是所有Spring模塊。如下圖:
二、事物配置詳解
1、全注解xml文件配置
<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" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <bean id="dataSourceMaster" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> <property name="driverClassName" value="${master.jdbc.driverClass}"/> <property name="url" value="${master.jdbc.url}"/> <property name="username" value="${master.jdbc.user}"/> <property name="password" value="${master.jdbc.password}"/> <property name="filters" value="stat"/> <property name="maxActive" value="200"/> <property name="initialSize" value="0"/> <property name="maxWait" value="60000"/> <property name="minIdle" value="0"/> <property name="timeBetweenEvictionRunsMillis" value="60000"/> <property name="minEvictableIdleTimeMillis" value="300000"/> <property name="validationQuery" value="SELECT 'x'"/> <property name="testWhileIdle" value="true"/> <property name="testOnBorrow" value="false"/> <property name="testOnReturn" value="false"/> </bean> <bean id="masterSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSourceMaster"/> <property name="configLocation" value="classpath:/mybatis/mybatis_config.xml"/> <property name="mapperLocations" value="classpath:mybatis/*Mapper.xml"/> </bean> <!-- mybatis mappers, scanned automatically --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.dao.mapper"/> <property name="sqlSessionFactoryBeanName" value="masterSqlSessionFactory"/> </bean> <bean id="sqlSessionMaster" class="org.mybatis.spring.SqlSessionTemplate" scope="prototype"> <constructor-arg index="0" ref="masterSqlSessionFactory"/> </bean> <!-- spring開啟事務控制的注解支持 --> <!-- MyBatis自動參與到spring事務管理中,無需額外配置, 只要org.mybatis.spring.SqlSessionFactoryBean引用的數據源 與DataSourceTransactionManager引用的數據源一致即可,否則事務管理會不起作用。--> <tx:annotation-driven transaction-manager="transactionManagerMaster" /> <bean id="transactionManagerMaster" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSourceMaster"/> </bean> </beans>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。