mybatis配置解析

一.引言:参考官方文档mybatis中提供了如下的配置,其中标红的需要掌握,其余的作为了解即可

二:配置解析之前的环境准备:进行配置之前要先有这几个东西,包括数据库表、Mybatis全局配置文件、实体类、mapper接口、mapper配置文件、用来连接数据库的工具类

  1.建库建表

 1 /*
 2 SQLyog Ultimate v12.09 (64 bit)
 3 MySQL - 5.7.24 : Database - mybatis
 4 *********************************************************************
 5 */
 6 
 7 
 8 /*!40101 SET NAMES utf8 */;
 9 
10 /*!40101 SET SQL_MODE=""*/;
11 
12 /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
13 /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
14 /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;
15 /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
16 CREATE DATABASE /*!32312 IF NOT EXISTS*/`mybatis` /*!40100 DEFAULT CHARACTER SET latin1 */;
17 
18 USE `mybatis`;
19 
20 /*Table structure for table `user` */
21 
22 DROP TABLE IF EXISTS `user`;
23 
24 CREATE TABLE `user` (
25   `id` int(20) NOT NULL,
26   `name` varchar(30) DEFAULT NULL,
27   `pwd` varchar(30) DEFAULT NULL,
28   PRIMARY KEY (`id`)
29 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
30 
31 /*Data for the table `user` */
32 
33 insert  into `user`(`id`,`name`,`pwd`) values (1,"xiaoma","123"),(2,"zhangsan","1234"),(3,"lisi","12345"),(4,"王五","1234"),(5,"王六","123456"),(6,"王五","123456");
34 
35 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
36 /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
37 /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
38 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 » mybatis配置解析