<?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. SpringMVC-06 Ajax

    SpringMVC-06 Ajax Ajax 1.简介 AJAX = Asynchronous JavaScript and XML(异步的 JavaScript 和 XML). AJAX 是一种在无 ...

  2. Eric Python IDE 论文数据图片生成

    Python编写,基于跨平台的Qt GUI工具包,集成了高度灵活的Scintilla编辑器控件. 大括号匹配,错误突出显示和可配置语法突出显示. 拼写检查库的集成 内置Python调试器,包括支持调试 ...

  3. POJ_2065 SETI 【同余高斯消元】

    一.题目  SETI 二.分析 给定一个模数,一串字符串,字符串长度为N,相当于是N个方程的答案,而这N个方程中有N个未知数,要求的就是这N个未知数的值,很显然的高斯消元,遇到模数和除法,用逆元就好. ...

  4. 最权威最简明的maven 使用教程

    Maven是一个项目管理工具,它包含了一个项目对象模型 (Project Object Model),一组标准集合,一个项目生命周期(Project Lifecycle),一个依赖管理系统(Depen ...

  5. Java 树结构实际应用 三(二叉排序树)

    二叉排序树 1 先看一个需求 给你一个数列 (7, 3, 10, 12, 5, 1, 9),要求能够高效的完成对数据的查询和添加   2 解决方案分析  使用数组 数组未排序, 优点:直接在数组尾添 ...

  6. python 查看模块中的方法

    way 1.help() way 2.dir() # dir() 函数不带参数时,返回当前范围内的变量.方法和定义的类型列表: way 3. 使用inspect模块, inspect.getmembe ...

  7. MySQL巩固学习记录(一)

    mysql下载安装 一.采用图形化界面安装 (初期只安装server服务端就可以了,别的不多赘述) 二.采用压缩版安装 1.将文件解压缩到自己想要的路径 2. 添加环境变量,即mysql的bin目录 ...

  8. [Fundamental of Power Electronics]-PART I-1.引言-1.1 功率处理概论

    1.1 功率处理概论 电力电子领域关注的是利用电子设备对电力进行处理[1–7].如图1.1所示,其中关键部件就是开关变换器.通常,开关变换器包含电源输入和控制输入端口以及电源输出端口.原始输入功率按控 ...

  9. Redis解读(1):Redis安装启动及常见数据类型

    Redis 简介 Redis 是我们在互联网应用中使用最广泛的一个 NoSQL 数据库,基于 C 开发的键值对存储数据库. Redis 这个名字是 Remote Dictionary Service ...

  10. JVMGC+Spring Boot生产部署和调参优化

    一.微服务开发完成,IDEA进行maven clean和package 出现BUILD SUCCESS说明打包成功 二.要求微服务启动时,配置JVM GC调优参数 p.p1 { margin: 0; ...