核心类生成-Mybatis Generator的使用
总结一下Generator的使用,首先要设计好数据表,然后修改generator.xml中的配制,接着直接运行命令就可以了。
第一步:数据库设计:
生成数据表代码:
/*
Navicat MySQL Data Transfer Source Server : localhost_3306
Source Server Version : 50722
Source Host : localhost:3306
Source Database : test1 Target Server Type : MYSQL
Target Server Version : 50722
File Encoding : 65001 Date: 2019-04-12 17:03:56
*/ SET FOREIGN_KEY_CHECKS=0; -- ----------------------------
-- Table structure for permission
-- ----------------------------
DROP TABLE IF EXISTS `permission`;
CREATE TABLE `permission` (
`pid` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
`url` varchar(255) DEFAULT '',
PRIMARY KEY (`pid`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; -- ----------------------------
-- Records of permission
-- ----------------------------
INSERT INTO `permission` VALUES ('', 'add', '');
INSERT INTO `permission` VALUES ('', 'delete', '');
INSERT INTO `permission` VALUES ('', 'edit', '');
INSERT INTO `permission` VALUES ('', 'query', ''); -- ----------------------------
-- Table structure for permission_role
-- ----------------------------
DROP TABLE IF EXISTS `permission_role`;
CREATE TABLE `permission_role` (
`rid` int(11) NOT NULL,
`pid` int(11) NOT NULL,
KEY `idx_rid` (`rid`),
KEY `idx_pid` (`pid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ----------------------------
-- Records of permission_role
-- ----------------------------
INSERT INTO `permission_role` VALUES ('', '');
INSERT INTO `permission_role` VALUES ('', '');
INSERT INTO `permission_role` VALUES ('', '');
INSERT INTO `permission_role` VALUES ('', '');
INSERT INTO `permission_role` VALUES ('', '');
INSERT INTO `permission_role` VALUES ('', ''); -- ----------------------------
-- Table structure for role
-- ----------------------------
DROP TABLE IF EXISTS `role`;
CREATE TABLE `role` (
`rid` int(11) NOT NULL AUTO_INCREMENT,
`rname` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`rid`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -- ----------------------------
-- Records of role
-- ----------------------------
INSERT INTO `role` VALUES ('', 'admin');
INSERT INTO `role` VALUES ('', 'customer'); -- ----------------------------
-- Table structure for sys_acl
-- ----------------------------
DROP TABLE IF EXISTS `sys_acl`;
CREATE TABLE `sys_acl` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '权限id',
`code` varchar(20) NOT NULL DEFAULT '' COMMENT '权限码',
`name` varchar(20) NOT NULL DEFAULT '' COMMENT '权限名称',
`acl_module_id` int(11) NOT NULL DEFAULT '' COMMENT '权限所在的权限模块id',
`url` varchar(100) NOT NULL DEFAULT '' COMMENT '请求的url, 可以填正则表达式',
`type` int(11) NOT NULL DEFAULT '' COMMENT '类型,1:菜单,2:按钮,3:其他',
`status` int(11) NOT NULL DEFAULT '' COMMENT '状态,1:正常,0:冻结',
`seq` int(11) NOT NULL DEFAULT '' COMMENT '权限在当前模块下的顺序,由小到大',
`remark` varchar(200) DEFAULT '' COMMENT '备注',
`operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者',
`operate_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后一次更新时间',
`operate_ip` varchar(20) NOT NULL DEFAULT '' COMMENT '最后一个更新者的ip地址',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4; -- ----------------------------
-- Records of sys_acl
-- ----------------------------
INSERT INTO `sys_acl` VALUES ('', '20171015095130_26', '进入产品管理界面', '', '/sys/product/product.page', '', '', '', '', 'Admin', '2017-10-15 09:51:30', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl` VALUES ('', '20171015095322_14', '查询产品列表', '', '/sys/product/page.json', '', '', '', '', 'Admin', '2017-10-15 09:53:22', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl` VALUES ('', '20171015095350_69', '产品上架', '', '/sys/product/online.json', '', '', '', '', 'Admin', '2017-10-15 09:53:51', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl` VALUES ('', '20171015095420_7', '产品下架', '', '/sys/product/offline.json', '', '', '', '', 'Admin', '2017-10-15 10:11:28', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl` VALUES ('', '20171015212626_63', '进入订单页', '', '/sys/order/order.page', '', '', '', '', 'Admin', '2017-10-15 21:26:27', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl` VALUES ('', '20171015212657_12', '查询订单列表', '', '/sys/order/list.json', '', '', '', '', 'Admin', '2017-10-15 21:26:57', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl` VALUES ('', '20171015212907_36', '进入权限管理页', '', '/sys/aclModule/acl.page', '', '', '', '', 'Admin', '2017-10-15 21:29:07', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl` VALUES ('', '20171015212938_27', '进入角色管理页', '', '/sys/role/role.page', '', '', '', '', 'Admin', '2017-10-16 17:49:38', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl` VALUES ('', '20171015213009_0', '进入用户管理页', '', '/sys/dept/dept.page', '', '', '', '', 'Admin', '2017-10-15 21:30:09', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl` VALUES ('', '20171016230429_8', '进入权限更新记录页面', '', '/sys/log/log.page', '', '', '', '', 'Admin', '2017-10-16 23:04:49', '0:0:0:0:0:0:0:1'); -- ----------------------------
-- Table structure for sys_acl_module
-- ----------------------------
DROP TABLE IF EXISTS `sys_acl_module`;
CREATE TABLE `sys_acl_module` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '权限模块id',
`name` varchar(20) NOT NULL DEFAULT '' COMMENT '权限模块名称',
`parent_id` int(11) NOT NULL DEFAULT '' COMMENT '上级权限模块id',
`level` varchar(200) NOT NULL DEFAULT '' COMMENT '权限模块层级',
`seq` int(11) NOT NULL DEFAULT '' COMMENT '权限模块在当前层级下的顺序,由小到大',
`status` int(11) NOT NULL DEFAULT '' COMMENT '状态,1:正常,0:冻结',
`remark` varchar(200) DEFAULT '' COMMENT '备注',
`operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者',
`operate_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后一次操作时间',
`operate_ip` varchar(20) NOT NULL DEFAULT '' COMMENT '最后一次更新操作者的ip地址',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; -- ----------------------------
-- Records of sys_acl_module
-- ----------------------------
INSERT INTO `sys_acl_module` VALUES ('', '产品管理', '', '', '', '', 'product', 'Admin', '2017-10-14 21:13:15', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl_module` VALUES ('', '订单管理', '', '', '', '', '', 'Admin', '2017-10-14 20:17:11', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl_module` VALUES ('', '公告管理', '', '', '', '', '', 'Admin', '2017-10-14 20:17:21', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl_module` VALUES ('', '出售中产品管理', '', '0.1', '', '', '', 'Admin', '2017-10-14 21:13:39', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl_module` VALUES ('', '下架产品管理', '', '0.1', '', '', '', 'Admin', '2017-10-14 20:18:02', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl_module` VALUES ('', '权限管理', '', '', '', '', '', 'Admin', '2017-10-15 21:27:37', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl_module` VALUES ('', '权限管理', '', '0.6', '', '', '', 'Admin', '2017-10-15 21:27:57', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl_module` VALUES ('', '角色管理', '', '0.6', '', '', '', 'Admin', '2017-10-15 21:28:22', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl_module` VALUES ('', '用户管理', '', '0.6', '', '', '', 'Admin', '2017-10-15 21:28:36', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl_module` VALUES ('', '运维管理', '', '', '', '', '', 'Admin', '2017-10-16 23:03:37', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_acl_module` VALUES ('', '权限更新记录管理', '', '0.6', '', '', '', 'Admin', '2017-10-16 23:04:07', '0:0:0:0:0:0:0:1'); -- ----------------------------
-- Table structure for sys_dept
-- ----------------------------
DROP TABLE IF EXISTS `sys_dept`;
CREATE TABLE `sys_dept` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '部门id',
`name` varchar(20) NOT NULL DEFAULT '' COMMENT '部门名称',
`parent_id` int(11) NOT NULL DEFAULT '' COMMENT '上级部门id',
`level` varchar(200) NOT NULL DEFAULT '' COMMENT '部门层级',
`seq` int(11) NOT NULL DEFAULT '' COMMENT '部门在当前层级下的顺序,由小到大',
`remark` varchar(200) DEFAULT '' COMMENT '备注',
`operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者',
`operate_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后一次操作时间',
`operate_ip` varchar(20) NOT NULL DEFAULT '' COMMENT '最后一次更新操作者的ip地址',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4; -- ----------------------------
-- Records of sys_dept
-- ----------------------------
INSERT INTO `sys_dept` VALUES ('', '技术部', '', '', '', '技术部', 'system', '2017-10-11 07:21:40', '127.0.0.1');
INSERT INTO `sys_dept` VALUES ('', '后端开发', '', '0.1', '', '后端', 'system-update', '2017-10-12 07:56:16', '127.0.0.1');
INSERT INTO `sys_dept` VALUES ('', '前端开发', '', '0.1', '', '', 'system-update', '2017-10-14 11:29:45', '127.0.0.1');
INSERT INTO `sys_dept` VALUES ('', 'UI设计', '', '0.1', '', '', 'system', '2017-10-12 07:55:43', '127.0.0.1');
INSERT INTO `sys_dept` VALUES ('', '产品部', '', '', '', '', 'Admin', '2017-10-16 22:52:29', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_dept` VALUES ('', '客服部', '', '', '', '', 'Admin', '2017-10-17 00:22:55', '0:0:0:0:0:0:0:1'); -- ----------------------------
-- Table structure for sys_log
-- ----------------------------
DROP TABLE IF EXISTS `sys_log`;
CREATE TABLE `sys_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` int(11) NOT NULL DEFAULT '' COMMENT '权限更新的类型,1:部门,2:用户,3:权限模块,4:权限,5:角色,6:角色用户关系,7:角色权限关系',
`target_id` int(11) NOT NULL COMMENT '基于type后指定的对象id,比如用户、权限、角色等表的主键',
`old_value` text COMMENT '旧值',
`new_value` text COMMENT '新值',
`operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者',
`operate_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后一次更新的时间',
`operate_ip` varchar(20) NOT NULL DEFAULT '' COMMENT '最后一次更新者的ip地址',
`status` int(11) NOT NULL DEFAULT '' COMMENT '当前是否复原过,0:没有,1:复原过',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4; -- ----------------------------
-- Records of sys_log
-- ----------------------------
INSERT INTO `sys_log` VALUES ('', '', '', '', '{\"id\":12,\"name\":\"客服部\",\"parentId\":0,\"level\":\"0\",\"seq\":3,\"operator\":\"Admin\",\"operateTime\":1508166002610,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:00:03', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '{\"id\":12,\"name\":\"客服部\",\"parentId\":0,\"level\":\"0\",\"seq\":3,\"operator\":\"Admin\",\"operateTime\":1508166003000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":12,\"name\":\"客服部\",\"parentId\":0,\"level\":\"0\",\"seq\":4,\"operator\":\"Admin\",\"operateTime\":1508166009313,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:00:09', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '', '{\"id\":4,\"username\":\"Kate\",\"telephone\":\"13144445555\",\"mail\":\"kate@qq.com\",\"password\":\"25D55AD283AA400AF464C76D713C07AD\",\"deptId\":1,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508166166297,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:02:46', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '{\"id\":4,\"username\":\"Kate\",\"telephone\":\"13144445555\",\"mail\":\"kate@qq.com\",\"password\":\"25D55AD283AA400AF464C76D713C07AD\",\"deptId\":1,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508166166000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":4,\"username\":\"Kate\",\"telephone\":\"13144445555\",\"mail\":\"kate@qq.com\",\"deptId\":1,\"status\":1,\"remark\":\"sss\",\"operator\":\"Admin\",\"operateTime\":1508166171320,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:02:51', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '', '{\"id\":10,\"name\":\"运维管理\",\"parentId\":0,\"level\":\"0\",\"seq\":5,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508166212527,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:03:33', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '{\"id\":10,\"name\":\"运维管理\",\"parentId\":0,\"level\":\"0\",\"seq\":5,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508166213000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":10,\"name\":\"运维管理\",\"parentId\":0,\"level\":\"0\",\"seq\":6,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508166217376,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:03:37', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '', '{\"id\":11,\"name\":\"权限更新记录管理\",\"parentId\":6,\"level\":\"0.6\",\"seq\":4,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508166246805,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:04:07', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '', '{\"id\":10,\"code\":\"20171016230429_8\",\"name\":\"进入权限更新记录页面\",\"aclModuleId\":1,\"url\":\"/sys/log/log.page\",\"type\":1,\"status\":1,\"seq\":1,\"operator\":\"Admin\",\"operateTime\":1508166269419,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:04:29', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '{\"id\":10,\"code\":\"20171016230429_8\",\"name\":\"进入权限更新记录页面\",\"aclModuleId\":1,\"url\":\"/sys/log/log.page\",\"type\":1,\"status\":1,\"seq\":1,\"operator\":\"Admin\",\"operateTime\":1508166269000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":10,\"name\":\"进入权限更新记录页面\",\"aclModuleId\":11,\"url\":\"/sys/log/log.page\",\"type\":1,\"status\":1,\"seq\":1,\"operator\":\"Admin\",\"operateTime\":1508166288589,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:04:49', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '', '{\"id\":5,\"name\":\"运维管理员\",\"type\":1,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508166301130,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:05:01', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '{\"id\":5,\"name\":\"运维管理员\",\"type\":1,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508166301000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":5,\"name\":\"运维管理员\",\"type\":1,\"status\":1,\"remark\":\"运维\",\"operator\":\"Admin\",\"operateTime\":1508166307317,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-16 23:05:07', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '[7,8,9]', '[7,8,9,10]', 'Admin', '2017-10-16 23:34:39', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '[1]', '[1,4]', 'Admin', '2017-10-16 23:34:44', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '', '{\"id\":5,\"username\":\"服务员A\",\"telephone\":\"18677778888\",\"mail\":\"service@qq.com\",\"password\":\"25D55AD283AA400AF464C76D713C07AD\",\"deptId\":12,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508170918338,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-17 00:21:58', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '{\"id\":5,\"username\":\"服务员A\",\"telephone\":\"18677778888\",\"mail\":\"service@qq.com\",\"password\":\"25D55AD283AA400AF464C76D713C07AD\",\"deptId\":12,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508170918000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":5,\"username\":\"服务员B\",\"telephone\":\"18677778888\",\"mail\":\"service@qq.com\",\"deptId\":12,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508170924698,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-17 00:22:05', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '{\"id\":5,\"username\":\"服务员B\",\"telephone\":\"18677778888\",\"mail\":\"service@qq.com\",\"password\":\"25D55AD283AA400AF464C76D713C07AD\",\"deptId\":12,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508170925000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":5,\"username\":\"服务员A\",\"telephone\":\"18677778888\",\"mail\":\"service@qq.com\",\"password\":\"25D55AD283AA400AF464C76D713C07AD\",\"deptId\":12,\"status\":1,\"operator\":\"Admin\",\"operateTime\":1508170934791,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-17 00:22:15', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '{\"id\":12,\"name\":\"客服部\",\"parentId\":0,\"level\":\"0\",\"seq\":4,\"operator\":\"Admin\",\"operateTime\":1508166009000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":12,\"name\":\"客服部A\",\"parentId\":0,\"level\":\"0\",\"seq\":4,\"operator\":\"Admin\",\"operateTime\":1508170966051,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-17 00:22:46', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '{\"id\":12,\"name\":\"客服部A\",\"parentId\":0,\"level\":\"0\",\"seq\":4,\"operator\":\"Admin\",\"operateTime\":1508170966000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":12,\"name\":\"客服部\",\"parentId\":0,\"level\":\"0\",\"seq\":4,\"operator\":\"Admin\",\"operateTime\":1508170975242,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-17 00:22:55', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '{\"id\":5,\"name\":\"运维管理员\",\"type\":1,\"status\":1,\"remark\":\"运维\",\"operator\":\"Admin\",\"operateTime\":1508166307000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":5,\"name\":\"运维管理员A\",\"type\":1,\"status\":1,\"remark\":\"运维\",\"operator\":\"Admin\",\"operateTime\":1508170997531,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-17 00:23:18', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '{\"id\":5,\"name\":\"运维管理员A\",\"type\":1,\"status\":1,\"remark\":\"运维\",\"operator\":\"Admin\",\"operateTime\":1508170998000,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', '{\"id\":5,\"name\":\"运维管理员\",\"type\":1,\"status\":1,\"remark\":\"运维\",\"operator\":\"Admin\",\"operateTime\":1508171007651,\"operateIp\":\"0:0:0:0:0:0:0:1\"}', 'Admin', '2017-10-17 00:23:28', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '[1,4]', '[1,4,2,3,5]', 'Admin', '2017-10-17 00:23:53', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '[1,4,2,3,5]', '[1,4]', 'Admin', '2017-10-17 00:24:04', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '[]', '[7,8,9,10]', 'Admin', '2017-10-17 00:24:23', '0:0:0:0:0:0:0:1', '');
INSERT INTO `sys_log` VALUES ('', '', '', '[7,8,9,10]', '[]', 'Admin', '2017-10-17 00:24:34', '0:0:0:0:0:0:0:1', ''); -- ----------------------------
-- Table structure for sys_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_role`;
CREATE TABLE `sys_role` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '角色id',
`name` varchar(20) NOT NULL,
`type` int(11) NOT NULL DEFAULT '' COMMENT '角色的类型,1:管理员角色,2:其他',
`status` int(11) NOT NULL DEFAULT '' COMMENT '状态,1:可用,0:冻结',
`remark` varchar(200) DEFAULT '' COMMENT '备注',
`operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者',
`operate_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后一次更新的时间',
`operate_ip` varchar(20) NOT NULL DEFAULT '' COMMENT '最后一次更新者的ip地址',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4; -- ----------------------------
-- Records of sys_role
-- ----------------------------
INSERT INTO `sys_role` VALUES ('', '产品管理员', '', '', '', 'Admin', '2017-10-15 12:42:47', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_role` VALUES ('', '订单管理员', '', '', '', 'Admin', '2017-10-15 12:18:59', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_role` VALUES ('', '公告管理员', '', '', '', 'Admin', '2017-10-15 12:19:10', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_role` VALUES ('', '权限管理员', '', '', '', 'Admin', '2017-10-15 21:30:36', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_role` VALUES ('', '运维管理员', '', '', '运维', 'Admin', '2017-10-17 00:23:28', '0:0:0:0:0:0:0:1'); -- ----------------------------
-- Table structure for sys_role_acl
-- ----------------------------
DROP TABLE IF EXISTS `sys_role_acl`;
CREATE TABLE `sys_role_acl` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`role_id` int(11) NOT NULL COMMENT '角色id',
`acl_id` int(11) NOT NULL COMMENT '权限id',
`operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者',
`operate_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后一次更新的时间',
`operate_ip` varchar(200) NOT NULL DEFAULT '' COMMENT '最后一次更新者的ip',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4; -- ----------------------------
-- Records of sys_role_acl
-- ----------------------------
INSERT INTO `sys_role_acl` VALUES ('', '', '', 'Admin', '2017-10-16 23:34:39', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_role_acl` VALUES ('', '', '', 'Admin', '2017-10-16 23:34:39', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_role_acl` VALUES ('', '', '', 'Admin', '2017-10-16 23:34:39', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_role_acl` VALUES ('', '', '', 'Admin', '2017-10-16 23:34:39', '0:0:0:0:0:0:0:1'); -- ----------------------------
-- Table structure for sys_role_user
-- ----------------------------
DROP TABLE IF EXISTS `sys_role_user`;
CREATE TABLE `sys_role_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`role_id` int(11) NOT NULL COMMENT '角色id',
`user_id` int(11) NOT NULL COMMENT '用户id',
`operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者',
`operate_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后一次更新的时间',
`operate_ip` varchar(20) NOT NULL DEFAULT '' COMMENT '最后一次更新者的ip地址',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4; -- ----------------------------
-- Records of sys_role_user
-- ----------------------------
INSERT INTO `sys_role_user` VALUES ('', '', '', 'Admin', '2017-10-17 00:24:04', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_role_user` VALUES ('', '', '', 'Admin', '2017-10-17 00:24:04', '0:0:0:0:0:0:0:1'); -- ----------------------------
-- Table structure for sys_user
-- ----------------------------
DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户id',
`username` varchar(20) NOT NULL DEFAULT '' COMMENT '用户名称',
`telephone` varchar(13) NOT NULL DEFAULT '' COMMENT '手机号',
`mail` varchar(20) NOT NULL DEFAULT '' COMMENT '邮箱',
`password` varchar(40) NOT NULL DEFAULT '' COMMENT '加密后的密码',
`dept_id` int(11) NOT NULL DEFAULT '' COMMENT '用户所在部门的id',
`status` int(11) NOT NULL DEFAULT '' COMMENT '状态,1:正常,0:冻结状态,2:删除',
`remark` varchar(200) DEFAULT '' COMMENT '备注',
`operator` varchar(20) NOT NULL DEFAULT '' COMMENT '操作者',
`operate_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后一次更新时间',
`operate_ip` varchar(20) NOT NULL DEFAULT '' COMMENT '最后一次更新者的ip地址',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4; -- ----------------------------
-- Records of sys_user
-- ----------------------------
INSERT INTO `sys_user` VALUES ('', 'Admin', '', 'admin@qq.com', '25D55AD283AA400AF464C76D713C07AD', '', '', 'admin', 'system', '2017-10-13 08:46:16', '127.0.0.1');
INSERT INTO `sys_user` VALUES ('', 'Jimin', '', 'jimin@qq.com', '25D55AD283AA400AF464C76D713C07AD', '', '', 'jimin.zheng', 'Admin', '2017-10-14 14:45:19', '127.0.0.1');
INSERT INTO `sys_user` VALUES ('', 'Jimmy', '', 'jimmy@qq.com', '25D55AD283AA400AF464C76D713C07AD', '', '', '', 'Admin', '2017-10-16 12:57:35', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_user` VALUES ('', 'Kate', '', 'kate@qq.com', '25D55AD283AA400AF464C76D713C07AD', '', '', 'sss', 'Admin', '2017-10-16 23:02:51', '0:0:0:0:0:0:0:1');
INSERT INTO `sys_user` VALUES ('', '服务员A', '', 'service@qq.com', '25D55AD283AA400AF464C76D713C07AD', '', '', '', 'Admin', '2017-10-17 00:22:15', '0:0:0:0:0:0:0:1'); -- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`uid` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL DEFAULT '',
`password` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`uid`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES ('', 'admin', '');
INSERT INTO `user` VALUES ('', 'demo', ''); -- ----------------------------
-- Table structure for user_role
-- ----------------------------
DROP TABLE IF EXISTS `user_role`;
CREATE TABLE `user_role` (
`uid` int(11) NOT NULL,
`rid` int(11) NOT NULL,
KEY `idx_uid` (`uid`),
KEY `idx_rid` (`rid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ----------------------------
-- Records of user_role
-- ----------------------------
INSERT INTO `user_role` VALUES ('', '');
INSERT INTO `user_role` VALUES ('', '');
第二步:把Generator工具包导入到项目中
数据库设计好以后,接下来开始导入Generator工具包到项目中。下载地址generator包我放到自己的csdn中,下载地址https://download.csdn.net/download/longyanchen/11110218
第三步:修改generator.xml
1.数据库驱动包位置
2.数据库链接URL、用户名、密码(案例mysql,数据库)
<!-- 数据库链接URL、用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/test1?characterEncoding=utf8" userId="root" password="123456"> <!-- 2 -->
</jdbcConnection>
3.生成模型的包名和位置
<!-- 生成模型的包名和位置 --> <!-- 3 -->
<javaModelGenerator targetPackage="com.mmall.model" targetProject="D:/IDEAProject/CYL/generator/src">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
4.生成的映射文件包名和位置
<!-- 生成的映射文件包名和位置 --> <!-- 4 -->
<sqlMapGenerator targetPackage="com.mmall.mapper" targetProject="D:/IDEAProject/CYL/generator/src">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
5.生成DAO的包名和位置
<!-- 生成DAO的包名和位置 --> <!-- 5 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.mmall.dao" targetProject="D:/IDEAProject/CYL/generator/src">
<property name="enableSubPackages" value="true" />
6.要生成那些表(更改tableName和domainObjectName(注意:tableName与domainObjectName的对应关系)
<!-- 要生成那些表(更改tableName和domainObjectName就可以) --><!-- 6 -->
<table tableName="sys_user" domainObjectName="SysUser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
<table tableName="sys_dept" domainObjectName="SysDept" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
<table tableName="sys_acl" domainObjectName="SysAcl" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
<table tableName="sys_acl_module" domainObjectName="SysAclModule" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
<table tableName="sys_role" domainObjectName="SysRole" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
<table tableName="sys_role_acl" domainObjectName="SysRoleAcl" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
<table tableName="sys_role_user" domainObjectName="SysRoleUser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
<table tableName="sys_log" domainObjectName="SysLog" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
第四步:生成核心代码
打开IDEA的Terminal,输入命令如下图所示
生成核心代码,将会出现你做配制的路径下。
核心类生成-Mybatis Generator的使用的更多相关文章
- MyBatis Generator 详解
MyBatis Generator中文文档 MyBatis Generator中文文档地址:http://mbg.cndocs.tk/ 该中文文档由于尽可能和原文内容一致,所以有些地方如果不熟悉,看中 ...
- MyBatis Generator 详解 【转来纯为备忘】
版权声明:版权归博主所有,转载请带上本文链接!联系方式:abel533@gmail.com 目录(?)[+] MyBatis Generator中文文档 运行MyBatis Generator X ...
- mybatis Generator配置文件详解
这里按照配置的顺序对配置逐个讲解,更细的内容可以配合中文文档参照. 1. 配置文件头 <?xml version="1.0" encoding="UTF-8&quo ...
- MyBatis Generator中文文档
MyBatis Generator中文文档 MyBatis Generator中文文档地址: http://mbg.cndocs.tk/ 该中文文档由于尽可能和原文内容一致,所以有些地方如果不熟悉,看 ...
- MyBatis Generator 详解(转)
MyBatis Generator中文文档 MyBatis Generator中文文档地址:http://mbg.cndocs.tk/ 该中文文档由于尽可能和原文内容一致,所以有些地方如果不熟悉,看中 ...
- mybatis generator的用法
1 自动生成代码 配置数据库 自动生成三个文件: 第一,java bean文件: 第二,java bean对应的dao文件,但是这里的dao只是一个接口: 第三,mybatis需要的Mapper文件: ...
- MyBatis Generator 详解 专题
idea中有plugin可提高效率: http://www.henryxi.com/use-idea-mybatis-plugin-generate-mapper-files eg: <?xml ...
- Mybatis详解系列(五)--Mybatis Generator和全注解风格的MyBatis3DynamicSql
简介 Mybatis Generator (MBG) 是 Mybatis 官方提供的代码生成器,通过它可以在项目中自动生成简单的 CRUD 方法,甚至"无所不能"的高级条件查询(M ...
- java web(七): mybatis的动态sql和mybatis generator自动生成pojo类和映射文件
前言: MyBatis 的强大特性之一便是它的动态 SQL.如果你有使用 JDBC 或其它类似框架的经验,你就能体会到根据 不同条件拼接 SQL 语句的痛苦.例如拼接时要确保不能忘记添加必要的空格,还 ...
随机推荐
- 小程序应用的Python服务器部署高配,依然是腾讯云秒杀阿里云!
上一篇文章,“小程序创业最低配置部署,腾讯云折扣秒杀阿里云!”介绍了小程序项目启动时的最低配置服务器选择,但当项目良好发展时,还是要把服务器配置调整到标准水平,承受住日益增长的流量访问. 随着Pyth ...
- IDEA中的.iml文件和.idea文件夹
.iml文件 iml文件是IntelliJ IDEA自动创建的模块文件,用于Java应用开发,存储一些模块开发相关的信息,比如一个Java组件,插件组件,Maven组件等等,还可能存储一些模块路径信息 ...
- Maven入门教程(一)
1.Maven的简介 1.1 什么是maven 是apache下的一个开源项目,是纯java开发,并且只是用来管理java项目的.Maven是一个项目管理工具,它包含了一个项目对象模型 (Projec ...
- 在centos中搭建基于nginx的apt源服务器,整合yum源和apt源在一台服务器
1.首先关闭防护墙或者设置规则通过且关闭selinux 2.nginx-1.14.2版本(编译安装)-自定义安装路径 3.开启nginx目录浏览 以上步骤请参考前文:https://www.cnblo ...
- Gitlab管理网页老是500错误?增加物理内存,增加cpu吧
上一篇 CentOS 7 系统下 GitLab 搭建 搭建时,是用的是1G内存, 访问gitlab管理网页非常慢,常常出现 500错误 查询后发现: Gitlab的运行对CPU是有要求的:2核心 支持 ...
- CentOS 安装 ceph 单机版(luminous版本)
一.环境准备 CentOS Linux release 7.4.1708 (Core)一台,4块磁盘(sda.sdb,.sdc.sdd) 192.168.27.130 nceph 二.配置环境 1.修 ...
- python defaultdict模块
from collections import defaultdict '''默认值字典'''d = defaultdict(lambda :123)print(d)print(type(d))pri ...
- 关于SSH的那些事
SSH: Secure Shell Protocol (安全外壳协议) Secure Shell,又可记为安全外壳协议(SSH) Secure Shell,又可记为安全外壳协议(SSH),最初是UN ...
- 在Bootstrap开发框架中使用Grid++报表
之前在随笔<在Winform开发中使用Grid++报表>介绍了在Winform环境中使用Grid++报表控件,本篇随笔介绍在Bootstrap开发框架中使用Grid++报表,也就是Web环 ...
- 02Spring Boot配置文件详解
02Spring Boot配置文件详解 文章指导 学习笔记 学习代码 自定义属性 在src/main/java/resources目录下创建一个application.properties或appli ...