<?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/cache http://www.springframework.org/schema/cache/spring-cache.xsd"> <!--Spring的配置文件 这里主要是配置和业务逻辑有关的--> <context:component-scan base-package="xyz.sun">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"></context:exclude-filter>
</context:component-scan> <!-- 数据源 事务控制器 xxx...-->
<context:property-placeholder location="classpath:dbconfig.properties" /> <bean id="pooledDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="jdbcUrl" value="${jdbc.jdbcUrl}"></property>
<property name="driverClass" value="${jdbc.driverClass}"></property>
<property name="user" value="${jdbc.user}"></property>
<property name="password" value="${jdbc.password}"></property> </bean> <!--==============================配置和mybatis整合====================================== -->
<bean id="SqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
<!--指定mybatis 全局配置文件的位置-->
<property name="configLocation" value="classpath:mybatis-config.xml"></property>
<property name="dataSource" ref="pooledDataSource"></property>
<!--指定mybatis mapper文件 的位置-->
<property name="mapperLocations" value="classpath:mapper/*.xml"></property>
</bean> <!--配置扫描器 将mybatis 接口的实现 加入到 ioc容器中-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!--扫描所有dao接口的实现, 加入到ioc容器中-->
<property name="basePackage" value="xyz.sun.crud.dao"></property>
</bean> <!--=====================事务控制的配置======================-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!--控制住数据源-->
<property name="dataSource" ref="pooledDataSource"></property>
</bean> <!--开启基于注解的事务, 也可以使用xml配置形式事务(必要主要的都是使用配置)-->
<aop:config>
<!-- 切入点表达式-->
<aop:pointcut expression="execution(* xyz.sun.crud.service..*(..))" id="txPoint" />
<!--配置事务增强 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPoint" />
</aop:config>
<!--配置事务增强 事务如何切入 -->
<!-- 配置事务属性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!--代表素偶有方法都是事务方法-->
<tx:method name="*" />
<!--以get 开始的所有方法-->
<tx:method name="get*" read-only="true" />
</tx:attributes>
</tx:advice> <!--Spring 配置文件的核心点 (数据源、与mybatis的整合 事务控制)-->
</beans>
jdbc.jdbcUrl=jdbc:mysql://localhost:3306/ssm_crud?useUnicode=true&characterEncoding=utf8&useSSL=true
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.user=root
jdbc.password=123456

截图:

最新文章

  1. python环境搭建-pycharm2016软件注册码
  2. TCP 四次握手
  3. git 添加ssh的方法 push免登陆
  4. Mixing Delphi and C++(相互调用)
  5. javascript进行url转义方法比较escape、encodeURI和encodeURIComponent
  6. Android开发优化之——对Bitmap的内存优化
  7. python成长笔记
  8. iptables的配置文件/etc/sysconfig/iptables不存在怎么办
  9. python 面向对象编程(一)
  10. JSONP的实现流程
  11. RxJS操作符(三)
  12. CodeForces 632C The Smallest String Concatenation//用string和sort就好了&amp;&amp;string的基础用法
  13. Java,mysql String与date类型转换
  14. 【Django】重定向
  15. nginx反向代理 强制https请求
  16. Linux安装命令出现如下错误:cannot find a valid baseurl for repo :base/7x86_64
  17. 使用pymysql
  18. Codeforces Round #378 (Div. 2) F - Drivers Dissatisfaction
  19. Oracle数据库将varchar类型的字段改为clob类型
  20. UML学习归纳整理

热门文章

  1. springboot整合mybatis。mapper.xml资源文件放置到resources文件夹下的配置&amp;别名使用配置
  2. java二叉树遍历——深度优先(DFS)与广度优先(BFS) 递归版与非递归版
  3. polay计数原理
  4. 根据数据渲染DOM树形菜单——中途感想
  5. 攻防世界 maze NJUPT CTF 2017
  6. go语言的初体验
  7. 【hacker101 CTF】Photo Gallery
  8. 学习一下 SpringCloud (六)-- 注册中心与配置中心 Nacos、网关 Gateway
  9. 分享15个实用VSCode插件,快来收藏吧!
  10. C语言const是如何保证变量不被修改的?