Spring实战之使用注解实现声明式事务操作示例-创新互联

本文实例讲述了Spring实战之使用注解实现声明式事务操作。分享给大家供大家参考,具体如下:

创新互联主要业务有网站营销策划、成都做网站、成都网站建设、微信公众号开发、微信小程序开发H5建站、程序开发等业务。一次合作终身朋友,是我们奉行的宗旨;我们不仅仅把客户当客户,还把客户视为我们的合作伙伴,在开展业务的过程中,公司还积累了丰富的行业经验、全网整合营销推广资源和合作伙伴关系资源,并逐渐建立起规范的客户服务和保障体系。 

一 配置文件

<?xml version="1.0" encoding="GBK"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://www.springframework.org/schema/beans"
   xmlns:p="http://www.springframework.org/schema/p"
   xmlns:aop="http://www.springframework.org/schema/aop"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
   http://www.springframework.org/schema/aop
   http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
   http://www.springframework.org/schema/tx
   http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
   <!-- 定义数据源Bean,使用C3P0数据源实现,并注入数据源的必要信息 -->
   <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
      destroy-method="close"
      p:driverClass="com.mysql.jdbc.Driver"
      p:jdbcUrl="jdbc:mysql://localhost/spring"
      p:user="root"
      p:password="32147"
      p:maxPoolSize="40"
      p:minPoolSize="2"
      p:initialPoolSize="2"
      p:maxIdleTime="30"/>
   <!-- 配置一个业务逻辑Bean -->
   <bean id="newsDao" class="org.crazyit.app.dao.impl.NewsDaoImpl"
      p:ds-ref="dataSource"/>
   <!-- 配置JDBC数据源的局部事务管理器,使用DataSourceTransactionManager 类 -->
   <!-- 该类实现PlatformTransactionManager接口,是针对采用数据源连接的特定实现-->
   <!-- 配置DataSourceTransactionManager时需要依注入DataSource的引用 -->
   <bean id="transactionManager"
      class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
      p:dataSource-ref="dataSource"/>
   <!-- 根据Annotation来生成事务代理 -->
   <tx:annotation-driven transaction-manager="transactionManager"/>
</beans>

另外有需要云服务器可以了解下创新互联建站www.cdcxhl.com,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

新闻标题:Spring实战之使用注解实现声明式事务操作示例-创新互联
分享路径:https://www.cdcxhl.com/article6/dpceog.html

成都网站建设公司_创新互联,为您提供微信公众号Google品牌网站制作App设计网站改版软件开发

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

外贸网站制作