<?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:context="http://www.springframework.org/schema/context"
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.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"
>
<!--开启aspectj aop 注解-->
<aop:aspectj-autoproxy/>
<context:component-scan base-package="com.tosit.cinema"/>

<!--声明数据源datasource-->

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:tosit"/>
<property name="username" value="cinema"/>
<property name="password" value="cinema"/>
</bean>

<!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!-- 自动扫描mapping.xml文件 -->
<!---->
<property name="mapperLocations" value="classpath:mapper/*.xml"/>
<!-- 扫描entity包 使用别名 -->
<property name="typeAliasesPackage" value="com.tosit.cinema.entity"/>
</bean>

<!-- DAO接口所在包名,Spring会自动查找其下的类 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.tosit.cinema.dao" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>

<!-- (事务管理)transaction manager, use JtaTransactionManager for global tx-->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!--定义事务声明 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<!-- the transactional semantics... -->
<tx:attributes>
<!-- all methods starting with 'get' are read-only -->
<tx:method name="get*" read-only="true" />
<tx:method name="list*" read-only="true" />
<tx:method name="find*" propagation="SUPPORTS" read-only="true" />
<tx:method name="paged*" propagation="SUPPORTS" read-only="true" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<!-- other methods use the default transaction settings (see below) -->
<tx:method name="*" />
</tx:attributes>
</tx:advice>

<aop:config>
<!-- 切入点 -->
<aop:pointcut id="businessService"
expression="execution(* com.tosit.cinema.service.*Service.*(..))" />
<!-- 定义事务拦截对应的通知 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="businessService" />
</aop:config>

<!--开启注解事务
<tx:annotation-driven/>-->

</beans>

转载于:https://www.cnblogs.com/kisshappyboy/p/9211525.html

spring.xml相关推荐

  1. applicationcontext添加配置_Spring源码分析2 — spring XML配置文件的解析流程

    1 介绍 创建并初始化spring容器中,关键一步就是读取并解析spring XML配置文件.这个过程比较复杂,本文将详细分析整个流程.先看涉及到的关键类. XmlWebApplicationCont ...

  2. Spring xml 配置使用外部config 文件

    Spring xml 配置使用外部config 文件 当使用Spring framework后, 我们一般会把db connection的信息写在spring的bean config xml里面. 例 ...

  3. myeclipse中配置spring xml自己主动提示

    版权声明: https://blog.csdn.net/zdp072/article/details/24582173 这是一篇分享技巧的文章:myeclipse中配置spring xml自己主动提示 ...

  4. 缘起 Dubbo ,讲讲 Spring XML Schema 扩展机制

    背景 在 Dubbo 中,可以使用 XML 配置相关信息,也可以用来引入服务或者导出服务.配置完成,启动工程,Spring 会读取配置文件,生成注入 相关 Bean.那 Dubbo 如何实现自定义 X ...

  5. ActiveMQ实战篇之 java和spring xml创建Broker(一)

    ActivityMQ创建broker是直接通过配置IOC注入的,所以了解如何用纯JAVA代码和spring xml 创建broker可以让我们对AcitivtyMQ有一个更深入的了解 原本的配置 &l ...

  6. springMVC通过spring.xml对属性注入bean值(工厂模式)

    springMVC通过spring.xml对属性注入bean值,该bean是一个map容器: <bean id="configXMLCreatorFactory" class ...

  7. [转] Spring XML配置十二个最佳实践

    Spring是一个强大的JAVA应用框架,广泛地应用于JAVA的应用程序.为Plain Old Java Objects(POJOs)提供企业级服务.Spring利用依赖注入机制来简化工作,同时提高易 ...

  8. spring.xml配置类属性--喜闻乐见

    相信大家在开发的过程中,都会写一些配置文件或者配置类来,毕竟好的编码习惯是不能硬编码的,所以配置文件和配置类就显得很重要了.但是我用久了之后发现,配置文件和配置类确实好用,但是假如有多个配置的话,那么 ...

  9. 【JAVA秘籍心法篇-Spring】Spring XML解析源码详解

    [JAVA秘籍心法篇-Spring]Spring XML解析源码详解 所谓天下武功,无坚不摧,唯快不破.但有又太极拳法以快制慢,以柔克刚.武功外式有拳打脚踢,刀剑棍棒,又有内功易筋经九阳神功.所有外功 ...

  10. elasticjob spring xml 代码分析

    elasticjob 的spring xml bean模式代码主要的入口是定义bean的NamespaceHandlerSupport ,包括zookeeper及3类job. zookeeper的Na ...

最新文章

  1. Timer定时器开发
  2. java 负数变正数 +
  3. 为何艾伦·图灵想让AI智能体故意犯错
  4. JavaScript基础知识(函数)
  5. Glide DiskCache 原理分析
  6. 删除Win7隐藏的系统分区
  7. confluence未授权模板注入/代码执行 cve-2019-3396
  8. 面试必会系列 - 1.2 Java 集合,源码讲解
  9. msyql 禁止远程访问
  10. Character Studio
  11. 离开小厂进大厂的第一周:我“后悔”了
  12. 光影之路 GPU架构发展史(3/4)
  13. keyboard dialog 仿微博表情键盘输入框
  14. cisco防火墙(Cisco防火墙型号asa)
  15. wordpress插件_适用于作家和写作的最佳WordPress插件
  16. Html5 postmessage 子父窗口传值
  17. 中国移动重置服务密码方法
  18. C语言经典69题(又易到难)每日更新5道题
  19. Linux环境变量PSI指什么,psi是什么单位(pSI指标应用原则)
  20. Number of ways to split should evenly divide the split dimension, but got split_dim 3 (size = 4) and

热门文章

  1. Day 1: Introduction to Deep Learning
  2. 2021-06-27Date时间
  3. JavaSE基础——多态、抽象类、接口
  4. Web(4)servlet
  5. 设计模式之GOF23责任链模式
  6. 十、Shell脚本编程
  7. Spark算子:RDD键值转换操作(5)–leftOuterJoin、rightOuterJoin、subtractByKey
  8. 阿里云ddns解决动态IP问题
  9. Oracle 常见错误代码处理 1
  10. Android 网络通信 之 UDP