---
title: "MyBatis3使用小结"
author: "sshzhangwg"
date: "2012-03-15T11:26:36Z"
tags: []
categories: ["数据库"]
slug: "mybatis3"
draft: false
lastmod: "2012-03-15T11:35:06Z"
id: 1454069
url: "https://aiappfine.iteye.com/blog/1454069"
---

使用mybatis3-spring进行数据库操作时，出现下面的异常：

 Exception in thread "main" java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for org.test.dao.TMpUserMapper.insert

 

   经过分析和实践，发现将TMpUserMapper.xml拷贝到dao.TMpUserMapper类所在的包下后，即使不在Configuration.xml中配置TMpUserMapper.xml的路径，也是可以的。这是因为mybatis-spring这个插件已经将ibatis的配置简化到最低，只需要配置applicationContext.xml即可，不需要理会mybatis的配置。

 

  归纳起来，1） 使用 mybatis-generator 生成vo、mapper、sample    2） 配置 applicationContext.xml

简单的CRUD基本上不需要写代码。