洞察如何选择适合你的企业的小程序开源框架来实现高效开发与管理
643
2022-12-13
mybatis mybatis
目录依赖配置CodeGenerator
mybatis-plus-generator + clickhouse 自动生成代码
依赖
mybatis-plus !-->
代码模板 !-->
mybatis-plus代码生成器 !-->
配置
mybatis-plus:
configuration:
map-underscore-to-camel-case: true
auto-mapping-behavior: full
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations: classpath*:mapper/**/*Mapper.xml
CodeGenerator
public class CodeGenerator {
private static final String REPLACE_LOCAL_PATH = "/target/test-classes/";
private static final String java_PATH = "/src/main/java";
public static void main(String[] args) {
// 获取项目路径
String projectPath = ClassLoader.getSystemResource("").getPath().replace(REPLACE_LOCAL_PATH, "");
// 全局配置
GlobalConfig gc = GeneratorBuilder.globalConfigBuilder()
.fileOverride().openDir(false)
.outputDir(projectPath + JAVA_PATH)
.author("generator")
.enableSwagger()
.commentDate("yyyy-MM-dd").build();
// 数据源配置
DataSourceConfig dsc = new DataSourceConfig.Builder("jdbc:clickhouse://ip:port", "user", "password")
.dbQuery(new ClickHouseQuery()).schema("schema").build();
// 包配置
PackageConfig pc = GeneratorBuilder.packageConfigBuilder().parent("com.study.clickhouse").build();
// 策略配置
StrategyConfig strategy = GeneratorBuilder.strategyConfigBuilder()
.addInclude("table_name")
.addTablePrefix(pc.getModuleName() + "_")
.controllerBuilder().enableHyphenStyle()
.entityBuilder()
.naming(NamingStrategy.underline_to_camel)
.columnNaming(NamingStrategy.underline_to_camel)
.versionColumnName("version").logicDeleteColumnName("isDelete")
.enableLombok()
.build();
TemplateConfig templateConfig = GeneratorBuilder.templateConfigBuilder().build();
// 代码生成器
AutoGenerator mpg = new AutoGenerator(dsc).global(gc).strategy(strategy).template(templateConfig).packageInfo(pc);
mpg.execute(new FGVrWQZCsireemarkerTemplateEngine());
}
}
click相关参考
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~