package genterator;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.InjectionConfig;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.DbType;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import java.util.*;
/**
* Created by CDHong on 2018/4/6.
*/
public class GenteratorCode {
public static void main(String[] args) throws InterruptedException {
//用来获取mybatis-plus.properties文件的配置信息
final ResourceBundle rb = ResourceBundle.getBundle("mybatis-plus");
AutoGenerator mpg = new AutoGenerator();
// 全局配置
GlobalConfig gc = new GlobalConfig();
gc.setOutputDir(rb.getString("OutputDir"));
gc.setFileOverride(true);
gc.setActiveRecord(true);
gc.setEnableCache(false);// XML 二级缓存
gc.setBaseResultMap(true);// XML ResultMap
gc.setBaseColumnList(true);// XML columList
gc.setAuthor(rb.getString("author"));
// 自定义文件命名,注意 %s 会自动填充表实体属性!
gc.setMapperName("%sMapper");
gc.setXmlName("%sMapper");
gc.setServiceName("I%sService");
gc.setServiceImplName("%sServiceImpl");
gc.setControllerName("%sController");
mpg.setGlobalConfig(gc);
// 数据源配置
DataSourceConfig dsc = new DataSourceConfig();
dsc.setDbType(DbType.ORACLE);
/*dsc.setTypeConvert(new MySqlTypeConvert(){
// 自定义数据库表字段类型转换【可选】
@Override
public DbColumnType processTypeConvert(String fieldType) {
System.out.println("转换类型:" + fieldType);
return super.processTypeConvert(fieldType);
}
});*/
dsc.setDriverName(rb.getString("oracle.driver"));
dsc.setUrl(rb.getString("oracle.url"));
dsc.setUsername(rb.getString("oracle.user"));
dsc.setPassword(rb.getString("oracle.pwd"));
mpg.setDataSource(dsc);
// 策略配置
StrategyConfig strategy = new StrategyConfig();
// strategy.setCapitalMode(true);// 全局大写命名 ORACLE 注意
//strategy.setTablePrefix(new String[] { "SYS_" });// 此处可以修改为您的表前缀
strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
strategy.setInclude(new String[] {"EMP","DEPT"}); // 需要生成的表
//strategy.setExclude(new String[]{"test"}); // 排除生成的表
mpg.setStrategy(strategy);
// 包配置
PackageConfig pc = new PackageConfig();
pc.setParent(rb.getString("parent"));
// pc.setModuleName("tbldept");//模块名称,单独生成模块时使用!!!!!!!!!!!
pc.setController("controller");
pc.setService("service");
pc.setServiceImpl("service.impl");
pc.setEntity("entity");
pc.setMapper("mapper");
mpg.setPackageInfo(pc);
// 注入自定义配置,可以在 VM 中使用 cfg.abc 【可无】
InjectionConfig cfg = new InjectionConfig() {
@Override
public void initMap() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("abc", this.getConfig().getGlobalConfig().getAuthor() + "-rb");
this.setMap(map);
}
};
// 调整 xml 生成目录演示
List<FileOutConfig> focList = new ArrayList<FileOutConfig>();
focList.add(new FileOutConfig("/templates/mapper.xml.vm") {
@Override
public String outputFile(TableInfo tableInfo) {
return rb.getString("OutputDirXml")+ "/mybatis/mappers/" + tableInfo.getEntityName() + "Mapper.xml";
}
});
cfg.setFileOutConfigList(focList);
mpg.setCfg(cfg);
// 关闭默认 xml 生成,调整生成 至 根目录
TemplateConfig tc = new TemplateConfig();
tc.setXml(null);
mpg.setTemplate(tc);
// 执行生成
mpg.execute();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
使用MybatisPlus+SpringMBVC完成的CUID以及分页查询实现Demo
共369个文件
gif:150个
xml:65个
js:38个
需积分: 27 31 下载量 62 浏览量
2018-04-08
12:18:20
上传
评论
收藏 17.13MB RAR 举报
温馨提示
使用MyBatisPlus的逆向工程自动生成Mapper接口,xml文件,service接口,service实现以及controller并整合Spring框架完成单表CUID和分页操作,代码讲解请参看:https://blog.csdn.net/u010158540/article/details/79833011
资源推荐
资源详情
资源评论
收起资源包目录
使用MybatisPlus+SpringMBVC完成的CUID以及分页查询实现Demo (369个子文件)
GenteratorCode.class 5KB
DeptController.class 4KB
DeptController.class 4KB
DeptTest.class 4KB
Emp.class 3KB
Emp.class 3KB
Dept.class 2KB
Dept.class 2KB
LayerJson.class 2KB
LayerJson.class 2KB
GenteratorCode$1.class 1KB
GenteratorCode$2.class 1KB
DeptServiceImpl.class 612B
DeptServiceImpl.class 612B
EmpServiceImpl.class 605B
EmpServiceImpl.class 605B
EmpController.class 472B
EmpController.class 472B
IDeptService.class 275B
IDeptService.class 275B
DeptMapper.class 272B
IEmpService.class 272B
DeptMapper.class 272B
IEmpService.class 272B
EmpMapper.class 269B
EmpMapper.class 269B
layui.css 59KB
layui.css 59KB
layer.css 14KB
layer.css 14KB
layui.mobile.css 10KB
layui.mobile.css 10KB
laydate.css 7KB
laydate.css 7KB
code.css 1KB
code.css 1KB
iconfont.eot 40KB
iconfont.eot 40KB
59.gif 10KB
59.gif 10KB
22.gif 10KB
22.gif 10KB
24.gif 8KB
24.gif 8KB
13.gif 7KB
13.gif 7KB
16.gif 7KB
16.gif 7KB
39.gif 6KB
39.gif 6KB
64.gif 6KB
64.gif 6KB
63.gif 6KB
63.gif 6KB
50.gif 6KB
50.gif 6KB
loading-0.gif 6KB
loading-0.gif 6KB
4.gif 6KB
4.gif 6KB
1.gif 5KB
1.gif 5KB
42.gif 5KB
42.gif 5KB
71.gif 5KB
71.gif 5KB
21.gif 5KB
21.gif 5KB
20.gif 5KB
20.gif 5KB
29.gif 5KB
29.gif 5KB
70.gif 4KB
70.gif 4KB
5.gif 4KB
5.gif 4KB
17.gif 4KB
17.gif 4KB
27.gif 4KB
27.gif 4KB
9.gif 4KB
9.gif 4KB
44.gif 4KB
44.gif 4KB
11.gif 4KB
11.gif 4KB
8.gif 4KB
8.gif 4KB
3.gif 4KB
3.gif 4KB
23.gif 4KB
23.gif 4KB
34.gif 4KB
34.gif 4KB
41.gif 4KB
41.gif 4KB
38.gif 4KB
38.gif 4KB
65.gif 3KB
65.gif 3KB
共 369 条
- 1
- 2
- 3
- 4
资源评论
CDHong.it
- 粉丝: 239
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功