Mybatis model、xml、mapper 生成

Mybatis model、xml、mapper 自动生成

使用步骤

step1 修改配置文件 resources/templates/gen.properties

# 驱动路径,可以为空,空值就会取默认mysql 驱动, 路径 jar/mysql-connector-java-5.1.47.jar
driverPath=

# db connect properties 数据库连接属性
# 注意在 xml 中 & 符号需要使用 &amp
# 关于转义字符 参考 https://www.w3school.com.cn/html/html_entities.asp)
driverClass=com.mysql.jdbc.Driver
jdbcUrl=jdbc:mysql://localhost:3306/test1?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&nullCatalogMeansCurrent=true
username=chengdu
password=chengdu

# model、xml、mapper gen path and pkg
# targetPath 生成代码路径, modelPkg 生成模型包路径
targetPath=code
modelPkg=scd.model
xmlPkg=scd.xml
mapperPkg=scd.mapper

# table、model、table tag
# 需要生成数据库的表,以及对应的模型名字,注意顺序对应关系
tables=t_article|t_task_param|t_test|t_user
models=ArticlePO|TaskParamPO|TestPO|UserPO
tableTagTemplate=<table tableName="${table}" domainObjectName="${model}" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>


# gen config path
# 生成 xml 配置文件路径, 模板文件固定在 resources 目录下面
configPath=temp

step2 run main

MyBatisProGen --> run

代码文件会在 targetPath 对应路径下生成

项目地址

https://github.com/shootercheng/codegen

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Chengdu.S

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值