小工具升级啦
我之前开发了一款定制化的代码生成工具,基于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文件编写工作一去不返。随时随地,方便快捷。
使用方式
我们只需要配置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。
整体配置文件内容如下:
生成结果
文件目录
Entity
mapper
service
service的实现类
controller
这款小插件根据公司实际需求定制生成代码,上述的代码全部由工具生成。相比于Mybatis-plus,更具备定制化。
小工具的源代码我已经上传到github上面了,有需要的可以留言或私聊我获取。