mybatis mybatis

网友投稿 643 2022-12-13

mybatis mybatis

mybatis mybatis

目录依赖配置CodeGenerator

mybatis-plus-generator + clickhouse 自动生成代码

依赖

mybatis-plus

com.baomidou

mybatis-plus-boot-starter

3.4.3.1

代码模板

org.freemarker

freemarker

mybatis-plus代码生成器

com.baomidou

mybatis-plus-generator

3.5.0

配置

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小时内删除侵权内容。

上一篇:企业降本增效建议书(降本增效意见建议)
下一篇:解决springcloud
相关文章

 发表评论

暂时没有评论,来抢沙发吧~