MyBatis 学习入门·基本配置·项目实例 & MyBatis 向Sql语句中动态传参数·动态SQL拼接 这两篇文章的
/* Navicat MySQL Data Transfer Source Server : Daley Source Server Version : 50716 Source Host : localhost:3306 Source Database : mybatis Target Server Type : MYSQL Target Server Version : 50716 File Encoding : 65001 Date: 2016-12-03 19:58:45 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for `message` -- ---------------------------- DROP TABLE IF EXISTS `message`; CREATE TABLE `message` ( `ID` int(11) NOT NULL, `COMMAND` varchar(16) DEFAULT NULL, `DESCRIPTION` varchar(32) DEFAULT NULL, `CONTENT` varchar(2048) DEFAULT NULL, PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of message -- ---------------------------- INSERT INTO `message` VALUES ('1', '你好', '你也好', '你也好'); INSERT INTO `message` VALUES ('2', 'Daley', '最帅的程序员', '....'); INSERT INTO `message` VALUES ('3', '你是谁', '我是Daley', '....'); INSERT INTO `message` VALUES ('4', '我帅吗', '童鞋 你是第二帅', '....');
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
更新:增加了机器人自动回复功能
GitHub项目地址:https://github.com/DaleyChao/MicroMessage/tree/2619a12afa2bb6a493c9824398fad7707dc08f90 Zip包:https://github.com/DaleyChao/MicroMessage/archive/2619a12afa2bb6a493c9824398fad7707dc08f90.zip\
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
更新:增加了机器人只能智能回复功能(多表查询)
(
tips:org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for Command.queryCommandList
### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for Command.queryCommandList
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
如果出现了上面这个报错,说明你忘记把新的sqlXML文件配置到Configuration.xml文件中)
配置多表需要创建两个实体类和相应的映射文件,具体怎么操作我就不说了,比较复杂。。。大家看例子吧
GitHub项目地址:https://github.com/DaleyChao/MicroMessage/tree/aa2c9232c216746810101fa1cbd87c7b236817e9 Zip包:https://github.com/DaleyChao/MicroMessage/archive/aa2c9232c216746810101fa1cbd87c7b236817e9.zip