<?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

截图:

Spring的配置文件 (SSM maven项目)的更多相关文章

  1. eclipse中SSM(maven)项目搭建全过程+实现用户登录功能

    项目创建之前确保eclipse中已经配置好了jdk,tomcat,maven如果没有配置下面有配置教程的链接   eclipse中配置jdk的教程url:http://www.cnblogs.com/ ...

  2. STS(Spring Tool Suite)创建maven项目

    右键菜单选择新建->maven项目 自己创建存放配置文件需要使用的maven文件夹

  3. Spring日记_01 之 Maven项目的创建和更新

    创建Maven项目: Maven是一个第三方工具用来 下载包的,将阿里云maven中的对应包的dependency 复制到maven项目的pom.xml文件中.就可以自动下载包(比如Spring-we ...

  4. 搭建springboot的ssm(spring + springmvc + mybatis)的maven项目

    最终项目目录结构 创建过程 1.创建开关SpringBootApplication 为了创建快速.我们使用idea自带的创建springboot来创建结构,当然创建普通的web项目也是可以的.(使用e ...

  5. spring tool suite处理 maven项目名称红色感叹号的问题

    今天构建一个springboot项目时,发现项目有个红色感叹号,但是pom.xml跟Build Path 都没问题. 解决方案: 选择 Windows --> show view --> ...

  6. ssm maven项目启动 报SYSTEM_PROPERTIES_MODE_ENVIRONMENT

    1.jar包冲突,查看项目中的jar和pom.xml中配置的jar包 版本,把没用的jar包删掉

  7. MyBatis Generator(SSM Maven项目)

    mbg.xml 放在项目目录里 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE genera ...

  8. dispatcherServlet-servlet.xml(SSM maven 项目)

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  9. web.xml 基本配置(SSM maven项目)

    <web-app> <display-name>Archetype Created Web Application</display-name> <!--we ...

随机推荐

  1. PriorityQueue 是线性结构吗?90%的人都搞错了!

    文章首发于「陈树义」公众号及个人博客 shuyi.tech 其实这个问题的完整描述是:Java 中的 PriorityQueue 实现,其数据的逻辑结构是线性结构吗?其数据的物理结构又是什么? 估计很 ...

  2. 攻防世界 reverser secret-galaxy-300

    secret-galaxy-300 school-ctf-winter-2015 运行程序 完全没有flag的身影呀 ida查看字符串 也没有相关信息 动态调试,看运行后内存信息 发现了一串字符 al ...

  3. JPEG解码——(6)IDCT逆离散余弦变换

    本篇是该系列的第六篇,承接上篇IZigZag变换,介绍接下来的一个步骤--逆离散余弦变换,即逆零偏置前的一个步骤. 该步骤比较偏理论,其业务是对IZigZag变换后的数据,再进一步的处理,使其恢复DC ...

  4. 第四单元总结&期末总结

    OO第四单元总结&期末总结 一.第四单元总结 第一次作业 在第四单元的作业中,我的架构是逐步演进的.设计第一次作业的架构时并没有考虑到后续作业会增加新的图,所以直接把类图的实现放在UmlInt ...

  5. 「HTML+CSS」--自定义加载动画【008】

    前言 Hello!小伙伴! 首先非常感谢您阅读海轰的文章,倘若文中有错误的地方,欢迎您指出- 哈哈 自我介绍一下 昵称:海轰 标签:程序猿一只|C++选手|学生 简介:因C语言结识编程,随后转入计算机 ...

  6. [Fundamental of Power Electronics]-PART II-7. 交流等效电路建模-7.2 基本交流建模方法

    7.2 基本交流建模方法 在本节中,PWM变换器的交流小信号模型导出步骤将被推导和解释.关键步骤是:(a)利用小纹波近似的动态版本,建立了与电感和电容波形的低频平均值相关的方程式,(b)平均方程的扰动 ...

  7. c++ 实现向量去重操作

    去重的时候要考虑线性表或链表是否是有序 1.1.无序线性表 对于向量[1,5,3,7,2,4,7,3], 从头开始扫描vector内的元素, 对于表中r处的元素a[r], 检查数组0至r-1区间内是否 ...

  8. SpringCloud LoadBalancer灰度策略实现

    如何使用 Spring Cloud 2020 中重磅推荐的负载均衡器 Spring Cloud LoadBalancer (下文简称 SCL),如何扩展负载均衡策略? 你将从本文中获取到答案 快速上手 ...

  9. Python:函数解释(面向过程)

    1. 函数概述 在编程的语境下,函数 (function) 是指一个有命名的.执行某个计算的语句序列 (sequence of statements) .函数可以针对某类问题建立了通用解决步骤(算法) ...

  10. HashSet、CopyOnWriteArraySet、ConcurrentSkipListSet源码解析(JDK1.8)

    目录 HashSet源码解析 HashSet简单使用的demo HashSet中的变量 HashSet的构造函数 HashSet的add方法 HashSet的iterator方法 HashSet的si ...