MyBatis-Spring整合之方式4
直接删除Mybatis的配置文件,修改Beans.xml文件的sqlSessionFactory的参数内容,如下:
<!--配置sqlSessionFactory-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mapperLocations" value="classpath:com/lxy/entity/*Mapper.xml"/>
<property name="configLocation" value=""/>
</bean>
修改Mapper.xml的别名,改用路径+类名,如下:
<mapper namespace="com.lxy.entity.UserMapper">
<select id="selectUsers" resultType="com.lxy.entity.User">
select * from users
</select>
<insert id="add" parameterType="com.lxy.entity.User" useGeneratedKeys="true">
insert into users(name,pwd) values(#{name},#{pwd})
</insert>
<delete id="remove">
delete from users where id=#{id}
</delete>
</mapper>
MyBatis-Spring整合之方式4的更多相关文章
- springMVC+mybatis+spring整合案例
1.web.xml a:配置spring监听,使web容器在启动时加载spring的applicationContext.xml <listener> <listener-class ...
- springMVC+MyBatis+Spring 整合(3)
spring mvc 与mybatis 的整合. 加入配置文件: spring-mybaits.xml <?xml version="1.0" encoding=" ...
- SpringMVC+Mybatis+Spring整合
Maven引入需要的JAR包 pom.xml <properties> <!-- spring版本号 --> <spring.version>4.0.2.RELEA ...
- MyBatis Spring整合配置映射接口类与映射xml文件
本文转自http://blog.csdn.net/zht666/article/details/38706083 Spring整合MyBatis使用到了mybatis-spring,在配置mybati ...
- Mybatis——Spring整合
一.引入依赖 Spring的相关jar包 mybatis-3.4.1.jar mybatis-spring-1.3.0.jar mysql-connector-java-5.1.37-bin.jar ...
- springMVC+MyBatis+Spring 整合(4) ---解决Spring MVC 对AOP不起作用的问题
解决Spring MVC 对AOP不起作用的问题 分类: SpringMVC3x+Spring3x+MyBatis3x myibaits spring J2EE2013-11-21 11:22 640 ...
- Mybatis+Spring整合后Mapper测试类编写
public class UserMapperTest { private ApplicationContext applicationContext; @Before public void ini ...
- springmvc+mybatis+spring 整合源码项目
A集成代码生成器 [正反双向(单表.主表.明细表.树形表,开发利器)+快速构建表单; freemaker模版技术 ,0个代码不用写,生成完整的一个模块,带页面.建表sql脚本,处理类,service等 ...
- springmvc+mybatis+spring 整合
获取[下载地址] [免费支持更新]三大数据库 mysql oracle sqlsever 更专业.更强悍.适合不同用户群体[新录针对本系统的视频教程,手把手教开发一个模块,快速掌握本系统] ...
- springmvc+mybatis+spring 整合 bootstrap
获取[下载地址] [免费支持更新]三大数据库 mysql oracle sqlsever 更专业.更强悍.适合不同用户群体[新录针对本系统的视频教程,手把手教开发一个模块,快速掌握本系统] ...
随机推荐
- docker部署java应用程序
https://docs.docker.com/get-started/ 安装docker 1.安装docker apt install docker 2.配置docker加速器 安装完成后在 ...
- 电脑进不去BIOS解决办法
把所有外设(主要是硬盘,包括装在主板上的固态硬盘)拆下来,拆下纽扣电池给主板放电,装回纽扣电池,重启F1进入BIOS. 最终查到原因,是固态那里出的问题,固态作为启动硬盘,被自己搞得有问题了,有两个启 ...
- 【Python】遍历循环
- TD - setAttribute()
添加指定的属性,并为其赋指定的值 this.sltLevelType.setAttribute("height", "100px");
- sql查询——子查询
-- 子查询 -- 一句查询语句内,再套一句查询语句 ,叫子查询 -- 查询班级类身高最高的人的名字 select name from students where high=(select max( ...
- JS高级---bind方法的使用
bind方法的使用 //通过对象,调用方法,产生随机数 function ShowRandom() { //1-10的随机数 this.number = parseInt(Math.random() ...
- mysql 查询时间戳格式化 和thinkphp查询时间戳转换
我在网上看了好多写的,都差不多,甚至好多都是一个人写的被别人转载啥的,哎 我写一个比较简单的 1.mysql语句 格式化时间戳 select id,name,FROM_UNIXTIME(time,'% ...
- CentOS 7 1810版本不能使用yum 命令
使用yum install httpd 命令安装Apache 提示错误 annot find a valid baseurl for repobase7x86_64 解决方法: 进入 ls命令寻找类似 ...
- Strange Bank(找零问题)
题目描述 为了使取钱变得困难,某家银行在一次操作中只允许其客户提取下列金额之一: 1日元(日本的货币) 6日元,62(=36)日元,63(=216)日元,… 9日元,92(=81)日元,93(=729 ...
- Go_Redis
Redis介绍 Redis是一个开源的内存数据库,Redis提供了多种不同类型的数据结构,很多业务场景下的问题都可以很自然地映射到这些数据结构上.除此之外,通过复制.持久化和客户端分片等特性,我们可以 ...