Spring跟mybatis结合
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
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/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/myData"></property>
<property name="username" value="root"></property>
<property name="password" value="root"></property>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="configLocation" value="classpath:mybatis-config.xml"></property>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="cn.zzw.dao"></property>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean>
<bean class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="cn.zzw.dao.UserMapper"></property>
<property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="ins*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut expression="execution(* cn.zzw.service.*.*(..))" id="ss"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="ss"/>
</aop:config>
<context:component-scan base-package="cn.zzw.service"></context:component-scan>
</beans>
Spring跟mybatis结合的更多相关文章
- spring整合mybatis使用<context:property-placeholder>时的坑
背景 最近项目要上线,需要开发一个数据迁移程序.程序的主要功能就是将一个数据库里的数据,查询出来经过一系列处理后导入另一个数据库.考虑到开发的方便快捷.自然想到用spring和mybatis整合一下. ...
- SSM三大框架整合详细教程(Spring+SpringMVC+MyBatis)【转】
使用SSM(Spring.SpringMVC和Mybatis)已经有三个多月了,项目在技术上已经没有什么难点了,基于现有的技术就可以实现想要的功能,当然肯定有很多可以改进的地方.之前没有记录SSM整合 ...
- Maven+Spring+Spring MVC+MyBatis+MySQL,搭建SSM框架环境【转】
项目建设完成之后的结构: 数据库的表结构如下: 环境建设:搭建Maven环境.Tomcat环境.需要MySql 数据库支持,使用的编程工具Eclipse (这些是前期准备): 开始创建工程: 1.创建 ...
- 基于Spring+SpringMVC+Mybatis的Web系统搭建
系统搭建的配置大同小异,本文在前人的基础上做了些许的改动,重写数据库,增加依据权限的动态菜单的实现,也增加了后台返回json格式数据的配置,详细参见完整源码. 主要的后端架构:Spring+Sprin ...
- Spring和Mybatis整合,配置文件
整合时除了未整合前spring.mybatis的必须包外还需要加入两个包 spring-jdbc-4.2.5.RELEASE.jar mybatis-spring-1.2.5.jar spring-j ...
- IDEA中maven搭建Spring+SpringMVC+mybatis项目
一.介绍 使用IDEA搭建maven web项目,整合框架Spring+SpringMVC+mybatis 项目结构图:
- 【JavaWeb】Spring+SpringMVC+MyBatis+SpringSecurity+EhCache+JCaptcha 完整Web基础框架(三)
Spring+SpringMVC MVC呢,现在似乎越来越流行使用SpringMVC框架,我自己用的感觉,是非常好,确实很舒服,配置一开始是麻烦了一点点,但是后续的开发真的是很清爽! SpringMV ...
- spring+springmvc+mybatis xml配置文件
一.jdbc.properties 文件: driver=com.mysql.jdbc.Driverurl=jdbc:mysql://192.168.31.xxx:3306/abc?useUnicod ...
- Spring+SpringMvc+Mybatis框架集成搭建教程
一.背景 最近有很多同学由于没有过SSM(Spring+SpringMvc+Mybatis , 以下简称SSM)框架的搭建的经历,所以在自己搭建SSM框架集成的时候,出现了这样或者那样的问题,很是苦恼 ...
- spring Mvc + Mybatis 中使用junit
在Spring Mvc + Mybatis的项目中我们有时候需要在测试代码中注入Dao操作数据库,对表进行增删改查,实现如下: 这是一般的maven项目项目结构 测试代码一般写在src/test/ja ...
随机推荐
- C# Winform 中DataGridView 实现单元格输入下拉框功能
https://blog.csdn.net/ad13adsa/article/details/82108969 private void dataGridViewX1_EditingControlSh ...
- go 笔记
Go 语言的变量声明格式为: var 变量名 变量类型 返回类型. 匿名变量不占用命名空间,不会分配内存.匿名变量与匿名变量之间也不会因为多次声明而无法使用. func GetData() (int, ...
- postgresql之json操作
--string 转 json select '{"Items":[{"Id":1,"InitStartDate":"2018-0 ...
- 浏览器输入URL后,HTTP请求返回的完整过程
1.Redirect,跳转 浏览器记录里这个地址永久跳转的新地址,浏览器先去判断需不需要跳转 2.Application cache ,应用缓存 浏览器看请求的资源是否有缓存 3.DNS解 ...
- 关于Struts2自动装配和访问Servlet API
自动装配 1.根据属性的getter和setter获取值 index.jsp <s:form action="hello" method="POST"& ...
- .net core json序列化 long类型转化成字符串
实现类 using System; using System.ComponentModel; using System.Linq; using Newtonsoft.Json; namespace H ...
- 第 10 章 容器监控 - 080 - Weave Scope 容器地图
Weave Scope 容器地图 Weave Scope 的最大特点是会自动生成一张 Docker 容器地图,让我们能够直观地理解.监控和控制容器. 安装 执行如下脚本安装运行 Weave Scope ...
- [JavaScript] 表单验证不通过不提交的JS写法
主要是本世纪初的写法.<script> function validateForm(f) { if (f.name.value == "") { alert(" ...
- Activiti之流程通过、驳回、会签、转办、中止、挂起等核心操作封装(Activiti5.9)
http://blog.csdn.net/rosten/article/details/38300267 package com.famousPro.process.service.impl; imp ...
- Cmake时 如何在windows命令行 选择vs版本
本人电脑装了VS2017 和 VS2013版本.可能时VS2017安装的时间早,每次cmake文件时优先选择编译成VS2017的文件 可通过查看VS2013的版本,使用 cmake ../pcl-su ...