import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
/**
* @Description:
* @Auther: chenmingjian
* @Date: 18-10-25 18:14
*/
public class CodeGenerator {
//代码生成器
private static AutoGenerator mpg = new AutoGenerator();
//全局配置
private static GlobalConfig gc = new GlobalConfig();
//作者、包名、去除表前缀
private static final String author = "chenmingjian";
private static final String package_name = "mybatisplus";
private static final String TABLE_PREFIX = "tb_";
//数据库
private static final String url = "jdbc:mysql://192.168.3.172:3306/test?useUnicode=true&useSSL=false&characterEncoding=utf8";
private static final String driverName = "";
private static final String userName = "devuser";
private static final String password = "dev123";
private static final String table_name = "tb_user";
public static void main(String[] args){
// 数据源配置
setDataSource();
// 全局配置
setGlobalConfig();
// 策略配置
setStrategy();
//执行
();
}
private static void setStrategy() {
StrategyConfig strategy = new StrategyConfig();
// 类名:Tb_userController -> TbUserController
(NamingStrategy.underline_to_camel);
// 属性名:start_time -> startTime
(NamingStrategy.underline_to_camel);
// lombok 代替 setter/getter等方法
(true);
// 设置Controller为RestController
(true);
//由数据库该表生成
(table_name);
//去除表前缀
(TABLE_PREFIX);
(strategy);
}
private static void setGlobalConfig() {
URL urlPath = ().getContextClassLoader().getResource("");
String projectPath = (urlPath).getPath().replace("target/classes", "src/main/java");
(projectPath);//代码生成位置
(true);//覆盖已有文件
(author);
gc.setSwagger2(true);
();//主键ID类型
(DateType.ONLY_DATE);//设置时间类型为Date
(gc);
PackageConfig pc = new PackageConfig();// 包配置
(package_name);
(pc);
}
private static void setDataSource() {
DataSourceConfig dsc = new DataSourceConfig();
(url);
(driverName);
(userName);
(password);
(dsc);
}
}