Spring的配置文件 (SSM maven项目)
<?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项目)的更多相关文章
- eclipse中SSM(maven)项目搭建全过程+实现用户登录功能
项目创建之前确保eclipse中已经配置好了jdk,tomcat,maven如果没有配置下面有配置教程的链接 eclipse中配置jdk的教程url:http://www.cnblogs.com/ ...
- STS(Spring Tool Suite)创建maven项目
右键菜单选择新建->maven项目 自己创建存放配置文件需要使用的maven文件夹
- Spring日记_01 之 Maven项目的创建和更新
创建Maven项目: Maven是一个第三方工具用来 下载包的,将阿里云maven中的对应包的dependency 复制到maven项目的pom.xml文件中.就可以自动下载包(比如Spring-we ...
- 搭建springboot的ssm(spring + springmvc + mybatis)的maven项目
最终项目目录结构 创建过程 1.创建开关SpringBootApplication 为了创建快速.我们使用idea自带的创建springboot来创建结构,当然创建普通的web项目也是可以的.(使用e ...
- spring tool suite处理 maven项目名称红色感叹号的问题
今天构建一个springboot项目时,发现项目有个红色感叹号,但是pom.xml跟Build Path 都没问题. 解决方案: 选择 Windows --> show view --> ...
- ssm maven项目启动 报SYSTEM_PROPERTIES_MODE_ENVIRONMENT
1.jar包冲突,查看项目中的jar和pom.xml中配置的jar包 版本,把没用的jar包删掉
- MyBatis Generator(SSM Maven项目)
mbg.xml 放在项目目录里 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE genera ...
- dispatcherServlet-servlet.xml(SSM maven 项目)
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- web.xml 基本配置(SSM maven项目)
<web-app> <display-name>Archetype Created Web Application</display-name> <!--we ...
随机推荐
- 2018.9.9 nowcoder 普及组第一场
2018.9.9 nowcoder 普及组第一场 C-括号 题目大意:一个只包含左右括号的字符串\(S\),希望删掉S中若干个字符,使得剩下的字符串是一个合法的括号串,有多少不同的方案. Soluti ...
- String 类的内存 解析
关于String类的内存解析 Person类的内存解析
- python对一个文本的解析
# 定义Tag的签注 controlAreaStart ="<ControlArea::黄冈>" controlAreaEnd = "</Control ...
- All I know about A/B Test (1) : 均值型指标与比值(率)型指标的计算区别
因为最近在找实习,所以打算把自己之前学过的关数据分析的知识总结(复习)一下.在总结A/B test时,我发现中文互联网中关于A/B test的总结已经很多了,但是对于均值型指标和比值(率)型指标在设计 ...
- python3 list合并
1 t1=[x for x in range(5)] 2 t2=[x for x in range(5,10)] 3 4 #way1:通过方法extend(),直接修改列表,无返回值 5 # t1.e ...
- OCPC产品初探
OCPC即Optimization CPC,今天我们就来看看它的Optimizaton在哪儿. 在广告模型初探(一)中我们就曾提到过,互联网广告的本质其实就是流量的买卖.是广告主.媒体方以及用户三方之 ...
- XML数据持久化学习笔记
一.XML基础语法 1.XML结构:XML是一种树结构的文本 2.XML注释:格式:<!--在其中书写注释-->,在注释中可以单行注释也可以多行注释 3.固定内容:<?xml ver ...
- 学习Typora来写博客
Typora学习 标题分级 知识详解 标题分级可使用快捷键Ctry+数字键(1.2.3.4.5.6.0) 例如Ctry+1为一级标题,Ctry+2为二级标题,以此类推,总共可分为六个级别的标题,Ctr ...
- [贪心]P1049 装箱问题
装箱问题 题目描述 有一个箱子容量为V(正整数,0≤V≤20000),同时有n个物品(0<n≤30),每个物品有一个体积(正整数). 要求n个物品中,任取若干个装入箱内,使箱子的剩余空间为最小. ...
- java面试-谈谈你对OOM的理解
一.OOM(OutOfMemoryError): 对象无法释放或无法被垃圾回收,造成内存浪费,导致程序运行速度减慢,甚至系统崩溃等严重后果,就是内存泄漏.多个内存泄漏造成可使用内存变少,会导致内存溢出 ...