mybatisgenerator生成service_还记得我之前的代码生成工具么,这次我给它升级了

小工具升级啦

我之前开发了一款定制化的代码生成工具,基于MyBatis Generator开发的。有有兴趣的可以看看我之前写的这篇文章:

MyBatis generator逆向生成实体类插件开发

(https://mp.weixin.qq.com/s?__biz=Mzg4NDMyNTIwMw==&mid=2247485580&idx=1&sn=6960d3c5d88a29efcbcfa466bdd99b9e&chksm=cfb8a6b0f8cf2fa6c2d8c0ce50343d9fafea029428f735ef075ee10eba509d62bf4e6c833eef&token=924485931&lang=zh_CN&scene=21#wechat_redirect)

当时这个款工具能一键生成实体类、Mapper类、Mapper的xml文件。但是远远满足不了公司的开发需求。为此,我对这款工具做了升级。

升级后的小插件可以生成实体类、Mapper类、Mapper的xml文件、Service、ServiceImpl、Controller。一秒生成,让机械无味的mybatis文件编写工作一去不返。随时随地,方便快捷。

使用方式

150a961cf607e7bd9866aa0ebd5952c7.png

我们只需要配置application.properties配置文件,然后启动Main类即可。

application文件配置如下:

数据库连接配置

#数据库连接配置datasource.url=jdbc:mysql://xxx:3306/rmp?characterEncoding=utf-8datasource.username=rootdatasource.password=xxxdatasource.driver-class-name=com.mysql.jdbc.Driver

生成代码地址

targetProjectPath=E:code

作者

#作者mybatis.author=lvshen

包名

#包名mybatis.controller=com.lvshen.rmp.controllermybatis.service=com.lvshen.rmp.servicemybatis.serviceImpl=com.lvshen.rmp.service.implmybatis.entity=com.lvshen.rmp.entitymybatis.mapper=com.lvshen.rmp.mapper

父类接口

#父类接口mybatis.rootModelInterface=com.xxx.rmp.entity.RmpBaseEntitymybatis.superServiceInterface=com.xxx.framework.base.service.BaseServicemybatis.superServiceImpl=com.xxx.framework.base.service.impl.BaseServiceImplmybatis.superController=com.xxx.basic.controller.BaseControllermybatis.rootMapperInterface=com.xxx.framework.base.mapper.BaseMapper

mapper文件的位置

#mapper文件的位置mybatis.resources=com.lvshen.rmp.mapper

要转实体的数据库表配置

#配置表->实体mybatis.table=rmp3_return_replacement_applymybatis.classname=ReturnReplacementApply

我们将rmp3_return_replacement_apply表转换生成实体ReturnReplacementApply。

整体配置文件内容如下:

93eae364e75b1935581741fb584da94f.png

生成结果

6a75e4ccec259918e27e9656e6923ffc.png

文件目录

Entity

93961c802d99d704fc365bb64afca7bd.png

mapper

ec2b87ae8380cf52800d695e57abbad9.png

service

af2b22b220c138fd4643d1af585f756d.png

service的实现类

5c2fb7a0867d2d3b963b36c6b02633b2.png

controller

c7154d1593f4579ed24a48aba286bcd4.png

这款小插件根据公司实际需求定制生成代码,上述的代码全部由工具生成。相比于Mybatis-plus,更具备定制化。

小工具的源代码我已经上传到github上面了,有需要的可以留言或私聊我获取。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值