Java Code Examples for com.baomidou.mybatisplus.generator.config.DataSourceConfig#setTypeConvert()
The following examples show how to use
com.baomidou.mybatisplus.generator.config.DataSourceConfig#setTypeConvert() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityGenerator.java From MeetingFilm with Apache License 2.0 | 4 votes |
@Test public void entityGenerator() { AutoGenerator mpg = new AutoGenerator(); // 全局配置 GlobalConfig gc = new GlobalConfig(); gc.setOutputDir("F:\\workSpace\\meeting_workspace\\meeting_film\\meeting_film_backend\\guns\\guns-alipay\\src\\main\\java");//这里写你自己的java目录 gc.setFileOverride(true);//是否覆盖 gc.setActiveRecord(true); gc.setEnableCache(false);// XML 二级缓存 gc.setBaseResultMap(true);// XML ResultMap gc.setBaseColumnList(false);// XML columList gc.setAuthor("jiangzh"); mpg.setGlobalConfig(gc); // 数据源配置 DataSourceConfig dsc = new DataSourceConfig(); dsc.setDbType(DbType.MYSQL); dsc.setTypeConvert(new MySqlTypeConvert() { // 自定义数据库表字段类型转换【可选】 @Override public DbColumnType processTypeConvert(String fieldType) { return super.processTypeConvert(fieldType); } }); dsc.setDriverName("com.mysql.jdbc.Driver"); dsc.setUsername("root"); dsc.setPassword(""); dsc.setUrl("jdbc:mysql://127.0.0.1:3306/guns_rest?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8"); mpg.setDataSource(dsc); // 策略配置 StrategyConfig strategy = new StrategyConfig(); //strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀 strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略 strategy.setInclude(new String[]{"mooc_order_2017_t"}); mpg.setStrategy(strategy); // 包配置 PackageConfig pc = new PackageConfig(); pc.setParent(null); pc.setEntity("com.stylefeng.guns.rest.common.persistence.model"); pc.setMapper("com.stylefeng.guns.rest.common.persistence.dao"); pc.setXml("com.stylefeng.guns.rest.common.persistence.dao.mapping"); pc.setService("TTT"); //本项目没用,生成之后删掉 pc.setServiceImpl("TTT"); //本项目没用,生成之后删掉 pc.setController("TTT"); //本项目没用,生成之后删掉 mpg.setPackageInfo(pc); // 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值 InjectionConfig cfg = new InjectionConfig() { @Override public void initMap() { Map<String, Object> map = new HashMap<>(); map.put("abc", this.getConfig().getGlobalConfig().getAuthor() + "-mp"); this.setMap(map); } }; mpg.setCfg(cfg); // 执行生成 mpg.execute(); // 打印注入设置 System.err.println(mpg.getCfg().getMap().get("abc")); }
Example 2
Source File: EntityGenerator.java From MeetingFilm with Apache License 2.0 | 4 votes |
@Test public void entityGenerator() { AutoGenerator mpg = new AutoGenerator(); // 全局配置 GlobalConfig gc = new GlobalConfig(); gc.setOutputDir("F:\\workSpace\\meeting_workspace\\meeting_film\\meeting_film_backend\\guns\\guns-order\\src\\main\\java");//这里写你自己的java目录 gc.setFileOverride(true);//是否覆盖 gc.setActiveRecord(true); gc.setEnableCache(false);// XML 二级缓存 gc.setBaseResultMap(true);// XML ResultMap gc.setBaseColumnList(false);// XML columList gc.setAuthor("jiangzh"); mpg.setGlobalConfig(gc); // 数据源配置 DataSourceConfig dsc = new DataSourceConfig(); dsc.setDbType(DbType.MYSQL); dsc.setTypeConvert(new MySqlTypeConvert() { // 自定义数据库表字段类型转换【可选】 @Override public DbColumnType processTypeConvert(String fieldType) { return super.processTypeConvert(fieldType); } }); dsc.setDriverName("com.mysql.jdbc.Driver"); dsc.setUsername("root"); dsc.setPassword(""); dsc.setUrl("jdbc:mysql://127.0.0.1:3306/guns_rest?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8"); mpg.setDataSource(dsc); // 策略配置 StrategyConfig strategy = new StrategyConfig(); //strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀 strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略 strategy.setInclude(new String[]{"mooc_order_2017_t","mooc_order_2018_t"}); mpg.setStrategy(strategy); // 包配置 PackageConfig pc = new PackageConfig(); pc.setParent(null); pc.setEntity("com.stylefeng.guns.rest.common.persistence.model"); pc.setMapper("com.stylefeng.guns.rest.common.persistence.dao"); pc.setXml("com.stylefeng.guns.rest.common.persistence.dao.mapping"); pc.setService("TTT"); //本项目没用,生成之后删掉 pc.setServiceImpl("TTT"); //本项目没用,生成之后删掉 pc.setController("TTT"); //本项目没用,生成之后删掉 mpg.setPackageInfo(pc); // 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值 InjectionConfig cfg = new InjectionConfig() { @Override public void initMap() { Map<String, Object> map = new HashMap<>(); map.put("abc", this.getConfig().getGlobalConfig().getAuthor() + "-mp"); this.setMap(map); } }; mpg.setCfg(cfg); // 执行生成 mpg.execute(); // 打印注入设置 System.err.println(mpg.getCfg().getMap().get("abc")); }
Example 3
Source File: EntityGenerator.java From MeetingFilm with Apache License 2.0 | 4 votes |
@Test public void entityGenerator() { AutoGenerator mpg = new AutoGenerator(); // 全局配置 GlobalConfig gc = new GlobalConfig(); gc.setOutputDir("F:\\workSpace\\meeting_workspace\\meeting_film\\meeting_film_backend\\guns\\guns-user\\src\\main\\java");//这里写你自己的java目录 gc.setFileOverride(true);//是否覆盖 gc.setActiveRecord(true); gc.setEnableCache(false);// XML 二级缓存 gc.setBaseResultMap(true);// XML ResultMap gc.setBaseColumnList(false);// XML columList gc.setAuthor("jiangzh"); mpg.setGlobalConfig(gc); // 数据源配置 DataSourceConfig dsc = new DataSourceConfig(); dsc.setDbType(DbType.MYSQL); dsc.setTypeConvert(new MySqlTypeConvert() { // 自定义数据库表字段类型转换【可选】 @Override public DbColumnType processTypeConvert(String fieldType) { return super.processTypeConvert(fieldType); } }); dsc.setDriverName("com.mysql.jdbc.Driver"); dsc.setUsername("root"); dsc.setPassword(""); dsc.setUrl("jdbc:mysql://127.0.0.1:3306/guns_rest?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8"); mpg.setDataSource(dsc); // 策略配置 StrategyConfig strategy = new StrategyConfig(); //strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀 strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略 strategy.setInclude(new String[]{"mooc_user_t"}); mpg.setStrategy(strategy); // 包配置 PackageConfig pc = new PackageConfig(); pc.setParent(null); pc.setEntity("com.stylefeng.guns.rest.common.persistence.model"); pc.setMapper("com.stylefeng.guns.rest.common.persistence.dao"); pc.setXml("com.stylefeng.guns.rest.common.persistence.dao.mapping"); pc.setService("TTT"); //本项目没用,生成之后删掉 pc.setServiceImpl("TTT"); //本项目没用,生成之后删掉 pc.setController("TTT"); //本项目没用,生成之后删掉 mpg.setPackageInfo(pc); // 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值 InjectionConfig cfg = new InjectionConfig() { @Override public void initMap() { Map<String, Object> map = new HashMap<>(); map.put("abc", this.getConfig().getGlobalConfig().getAuthor() + "-mp"); this.setMap(map); } }; mpg.setCfg(cfg); // 执行生成 mpg.execute(); // 打印注入设置 System.err.println(mpg.getCfg().getMap().get("abc")); }
Example 4
Source File: EntityGenerator.java From MeetingFilm with Apache License 2.0 | 4 votes |
@Test public void entityGenerator() { AutoGenerator mpg = new AutoGenerator(); // 全局配置 GlobalConfig gc = new GlobalConfig(); gc.setOutputDir("D:\\tmp\\guns\\guns-rest\\src\\main\\java");//这里写你自己的java目录 gc.setFileOverride(true);//是否覆盖 gc.setActiveRecord(true); gc.setEnableCache(false);// XML 二级缓存 gc.setBaseResultMap(true);// XML ResultMap gc.setBaseColumnList(false);// XML columList gc.setAuthor("stylefeng"); mpg.setGlobalConfig(gc); // 数据源配置 DataSourceConfig dsc = new DataSourceConfig(); dsc.setDbType(DbType.MYSQL); dsc.setTypeConvert(new MySqlTypeConvert() { // 自定义数据库表字段类型转换【可选】 @Override public DbColumnType processTypeConvert(String fieldType) { return super.processTypeConvert(fieldType); } }); dsc.setDriverName("com.mysql.jdbc.Driver"); dsc.setUsername("root"); dsc.setPassword("root"); dsc.setUrl("jdbc:mysql://127.0.0.1:3306/rest?characterEncoding=utf8"); mpg.setDataSource(dsc); // 策略配置 StrategyConfig strategy = new StrategyConfig(); //strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀 strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略 strategy.setInclude(new String[]{"user"}); mpg.setStrategy(strategy); // 包配置 PackageConfig pc = new PackageConfig(); pc.setParent(null); pc.setEntity("com.stylefeng.guns.rest.persistence.model"); pc.setMapper("com.stylefeng.guns.rest.persistence.dao"); pc.setXml("com.stylefeng.guns.rest.persistence.dao.mapping"); pc.setService("TTT"); //本项目没用,生成之后删掉 pc.setServiceImpl("TTT"); //本项目没用,生成之后删掉 pc.setController("TTT"); //本项目没用,生成之后删掉 mpg.setPackageInfo(pc); // 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值 InjectionConfig cfg = new InjectionConfig() { @Override public void initMap() { Map<String, Object> map = new HashMap<>(); map.put("abc", this.getConfig().getGlobalConfig().getAuthor() + "-mp"); this.setMap(map); } }; mpg.setCfg(cfg); // 执行生成 mpg.execute(); // 打印注入设置 System.err.println(mpg.getCfg().getMap().get("abc")); }
Example 5
Source File: EntityGenerator.java From MeetingFilm with Apache License 2.0 | 4 votes |
@Test public void entityGenerator() { AutoGenerator mpg = new AutoGenerator(); // 全局配置 GlobalConfig gc = new GlobalConfig(); gc.setOutputDir("G:\\BaiduNetdiskDownload\\应用Dubbo框架打造仿猫眼项目\\MeetingFilm\\guns-cinema\\src\\main\\java");//这里写你自己的java目录 gc.setFileOverride(true);//是否覆盖 gc.setActiveRecord(true); gc.setEnableCache(false);// XML 二级缓存 gc.setBaseResultMap(true);// XML ResultMap gc.setBaseColumnList(false);// XML columList gc.setAuthor("jiangzh"); mpg.setGlobalConfig(gc); // 数据源配置 DataSourceConfig dsc = new DataSourceConfig(); dsc.setDbType(DbType.MYSQL); dsc.setTypeConvert(new MySqlTypeConvert() { // 自定义数据库表字段类型转换【可选】 @Override public DbColumnType processTypeConvert(String fieldType) { return super.processTypeConvert(fieldType); } }); dsc.setDriverName("com.mysql.jdbc.Driver"); dsc.setUsername("root"); dsc.setPassword("123456789qwER#"); dsc.setUrl("jdbc:mysql://119.3.214.253:3306/guns_rest?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8"); mpg.setDataSource(dsc); // 策略配置 StrategyConfig strategy = new StrategyConfig(); //strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀 strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略 // strategy.setInclude(new String[]{"mooc_banner_t","mooc_cat_dict_t","mooc_area_dict_t","mooc_year_dict_t","mooc_film_t","mooc_film_info_t","mooc_actor_t"}); // strategy.setInclude(new String[]{"mooc_source_dict_t"}); strategy.setInclude(new String[]{"mooc_hall_film_info_t"}); mpg.setStrategy(strategy); // 包配置 PackageConfig pc = new PackageConfig(); pc.setParent(null); pc.setEntity("com.stylefeng.guns.rest.common.persistence.model"); pc.setMapper("com.stylefeng.guns.rest.common.persistence.dao"); pc.setXml("com.stylefeng.guns.rest.common.persistence.dao.mapping"); pc.setService("TTT"); //本项目没用,生成之后删掉 pc.setServiceImpl("TTT"); //本项目没用,生成之后删掉 pc.setController("TTT"); //本项目没用,生成之后删掉 mpg.setPackageInfo(pc); // 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值 InjectionConfig cfg = new InjectionConfig() { @Override public void initMap() { Map<String, Object> map = new HashMap<>(); map.put("abc", this.getConfig().getGlobalConfig().getAuthor() + "-mp"); this.setMap(map); } }; mpg.setCfg(cfg); // 执行生成 mpg.execute(); // 打印注入设置 System.err.println(mpg.getCfg().getMap().get("abc")); }
Example 6
Source File: EntityGenerator.java From MeetingFilm with Apache License 2.0 | 4 votes |
@Test public void entityGenerator() { AutoGenerator mpg = new AutoGenerator(); // 全局配置 GlobalConfig gc = new GlobalConfig(); gc.setOutputDir("D:\\tmp\\guns\\guns-rest\\src\\main\\java");//这里写你自己的java目录 gc.setFileOverride(true);//是否覆盖 gc.setActiveRecord(true); gc.setEnableCache(false);// XML 二级缓存 gc.setBaseResultMap(true);// XML ResultMap gc.setBaseColumnList(false);// XML columList gc.setAuthor("stylefeng"); mpg.setGlobalConfig(gc); // 数据源配置 DataSourceConfig dsc = new DataSourceConfig(); dsc.setDbType(DbType.MYSQL); dsc.setTypeConvert(new MySqlTypeConvert() { // 自定义数据库表字段类型转换【可选】 @Override public DbColumnType processTypeConvert(String fieldType) { return super.processTypeConvert(fieldType); } }); dsc.setDriverName("com.mysql.jdbc.Driver"); dsc.setUsername("root"); dsc.setPassword("root"); dsc.setUrl("jdbc:mysql://127.0.0.1:3306/rest?characterEncoding=utf8"); mpg.setDataSource(dsc); // 策略配置 StrategyConfig strategy = new StrategyConfig(); //strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀 strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略 strategy.setInclude(new String[]{"user"}); mpg.setStrategy(strategy); // 包配置 PackageConfig pc = new PackageConfig(); pc.setParent(null); pc.setEntity("com.stylefeng.guns.rest.persistence.model"); pc.setMapper("com.stylefeng.guns.rest.persistence.dao"); pc.setXml("com.stylefeng.guns.rest.persistence.dao.mapping"); pc.setService("TTT"); //本项目没用,生成之后删掉 pc.setServiceImpl("TTT"); //本项目没用,生成之后删掉 pc.setController("TTT"); //本项目没用,生成之后删掉 mpg.setPackageInfo(pc); // 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值 InjectionConfig cfg = new InjectionConfig() { @Override public void initMap() { Map<String, Object> map = new HashMap<>(); map.put("abc", this.getConfig().getGlobalConfig().getAuthor() + "-mp"); this.setMap(map); } }; mpg.setCfg(cfg); // 执行生成 mpg.execute(); // 打印注入设置 System.err.println(mpg.getCfg().getMap().get("abc")); }
Example 7
Source File: EntityGenerator.java From MeetingFilm with Apache License 2.0 | 4 votes |
@Test public void entityGenerator() { AutoGenerator mpg = new AutoGenerator(); // 全局配置 GlobalConfig gc = new GlobalConfig(); gc.setOutputDir("F:\\workSpace\\meeting_workspace\\meeting_film\\meeting_film_backend\\guns\\guns-film\\src\\main\\java");//这里写你自己的java目录 gc.setFileOverride(true);//是否覆盖 gc.setActiveRecord(true); gc.setEnableCache(false);// XML 二级缓存 gc.setBaseResultMap(true);// XML ResultMap gc.setBaseColumnList(false);// XML columList gc.setAuthor("jiangzh"); mpg.setGlobalConfig(gc); // 数据源配置 DataSourceConfig dsc = new DataSourceConfig(); dsc.setDbType(DbType.MYSQL); dsc.setTypeConvert(new MySqlTypeConvert() { // 自定义数据库表字段类型转换【可选】 @Override public DbColumnType processTypeConvert(String fieldType) { return super.processTypeConvert(fieldType); } }); dsc.setDriverName("com.mysql.jdbc.Driver"); dsc.setUsername("root"); dsc.setPassword(""); dsc.setUrl("jdbc:mysql://127.0.0.1:3306/guns_rest?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8"); mpg.setDataSource(dsc); // 策略配置 StrategyConfig strategy = new StrategyConfig(); //strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀 strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略 // strategy.setInclude(new String[]{"mooc_banner_t","mooc_cat_dict_t","mooc_area_dict_t","mooc_year_dict_t","mooc_film_t","mooc_film_info_t","mooc_actor_t"}); // strategy.setInclude(new String[]{"mooc_source_dict_t"}); strategy.setInclude(new String[]{"mooc_film_actor_t"}); mpg.setStrategy(strategy); // 包配置 PackageConfig pc = new PackageConfig(); pc.setParent(null); pc.setEntity("com.stylefeng.guns.rest.common.persistence.model"); pc.setMapper("com.stylefeng.guns.rest.common.persistence.dao"); pc.setXml("com.stylefeng.guns.rest.common.persistence.dao.mapping"); pc.setService("TTT"); //本项目没用,生成之后删掉 pc.setServiceImpl("TTT"); //本项目没用,生成之后删掉 pc.setController("TTT"); //本项目没用,生成之后删掉 mpg.setPackageInfo(pc); // 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值 InjectionConfig cfg = new InjectionConfig() { @Override public void initMap() { Map<String, Object> map = new HashMap<>(); map.put("abc", this.getConfig().getGlobalConfig().getAuthor() + "-mp"); this.setMap(map); } }; mpg.setCfg(cfg); // 执行生成 mpg.execute(); // 打印注入设置 System.err.println(mpg.getCfg().getMap().get("abc")); }