配置方式配置事務

2021-10-08 14:56:47 字數 1659 閱讀 2394

配置了事務管理器

配置了切點(dao層的對應的方法)

配置了切面(事務的傳播行為,隔離級別)

<

!-- 讀取資料庫配置檔案--

>

"db.properties"

>

<

/context:property-placeholder>

<

!-- 初始化 資料來源--

>

"datasource" class=

"com.alibaba.druid.pool.druiddatasource" init-method=

"init" destroy-method=

"close"

>

"driverclassname" value=

"$"/

>

"url" value=

"$"/

>

"username" value=

"$"/

>

"password" value=

"$"/

>

<

/bean>

<

!--連線池--

>

"jdbctemplate" class=

"org.springframework.jdbc.core.jdbctemplate"

>

"datasource" ref=

"datasource"

>

<

/property>

<

/bean>

<

!--配置事務管理器--

>

"txmanager" class=

"org.springframework.jdbc.datasource.datasourcetransactionmanager"

>

"datasource" ref=

"datasource"

>

<

/property>

<

/bean>

<

!-- 切面--

>

<

!-- 指定位置進行增強 --

>

"useradvice" pointcut=

"execution(* com.uu.translation.dao.*.*(..))"

>

<

/aop:advisor>

<

/aop:config>

<

!-- 事務管理器--

>

"useradvice" transaction-manager=

"txmanager"

>

<

!-- 要加上事務的方法,隔離級別,傳播行為--

>

"insert*" propagation=

"mandatory" isolation=

"read_committed" read-only=

"false"

/>

<

/tx:attributes>

<

/tx:advice>

spring 配置事務 配置檔案方式

xmlns xsi xmlns aop xmlns tx xmlns jdbc xmlns p xsi schemalocation spring beans 3.0.xsd spring jdbc 3.0.xsd spring aop 3.0.xsd spring tx 3.0.xsd destr...

Spring宣告式事務(xml配置事務方式)

spring宣告式事務 xml配置事務方式 蕃薯耀 2016年5月24日 10 12 13 星期二 xlm配置如下 注意 當事務切點配置成這樣時 即expression中紅色標記的地方 expression execution com.lqy.spring.iwx.service.impl.配置成這...

Spring宣告式事務(xml配置事務方式)

spring宣告式事務 xml配置事務方式 蕃薯耀 2016年5月24日 10 12 13 星期二 xlm配置如下 注意 當事務切點配置成這樣時 即expression中紅色標記的地方 expression execution com.lqy.spring.iwx.service.impl.配置成這...