ssm整合之Spring整合MyBatis框架配置事務(wù)的詳細(xì)教程-創(chuàng)新互聯(lián)

ssm整合之Spring整合MyBatis框架配置事務(wù)

創(chuàng)新互聯(lián)堅持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站設(shè)計、網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時代的溧水網(wǎng)站設(shè)計、移動媒體設(shè)計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

1.在applicationContext.xml修改代碼如下:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="/tupian/20230522/"
    xmlns:xsi="/tupian/20230522/XMLSchema-instance"
    xmlns:context="/tupian/20230522/"
    xmlns:aop="/tupian/20230522/"
    xmlns:tx="/tupian/20230522/"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
	/tupian/20230522/spring-beans.xsd
	http://www.springframework.org/schema/context
	/tupian/20230522/spring-context.xsd
	http://www.springframework.org/schema/aop
	/tupian/20230522/spring-aop.xsd
	http://www.springframework.org/schema/tx
	http://www.springframework.org/schema/tx/spring-tx.xsd">
  <!--開啟注解的掃描,希望處理service和dao,controller不需要Spring框架去處理-->
  <context:component-scan base-package="com.txw">
    <!--配置哪些注解不掃描-->
    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
  </context:component-scan>
  <!--Spring整合MyBatis框架-->
  <!--配置連接池-->
  <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="driverClass" value="com.mysql.jdbc.Driver"/>
    <property name="jdbcUrl" value="jdbc:mysql:///ssm"/>
    <property name="user" value="root"/>
    <property name="password" value="123456"/>
  </bean>
  <!--配置SqlSessionFactory工廠-->
  <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
  </bean>
  <!--配置AccountDao接口所在包-->
  <bean id="mapperScanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="com.txw.dao"/>
  </bean>
  <!--配置Spring框架聲明式事務(wù)管理-->
  <!--配置事務(wù)管理器-->
  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
  </bean>
  <!--配置事務(wù)通知-->
  <tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
      <tx:method name="find*" read-only="true"/>
      <tx:method name="*" isolation="DEFAULT"/>
    </tx:attributes>
  </tx:advice>
  <!--配置AOP增強(qiáng)-->
  <aop:config>
    <aop:advisor advice-ref="txAdvice" pointcut="execution(* com.txw.service.impl.*ServiceImpl.*(..))"/>
  </aop:config>
</beans>

網(wǎng)站名稱:ssm整合之Spring整合MyBatis框架配置事務(wù)的詳細(xì)教程-創(chuàng)新互聯(lián)
網(wǎng)頁鏈接:http://bm7419.com/article22/ddpgcc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計、營銷型網(wǎng)站建設(shè)、網(wǎng)站排名、靜態(tài)網(wǎng)站、品牌網(wǎng)站建設(shè)、移動網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都做網(wǎng)站