Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

项目使用文档 #3

Open
Rainsli opened this issue Aug 18, 2021 · 0 comments
Open

项目使用文档 #3

Rainsli opened this issue Aug 18, 2021 · 0 comments

Comments

@Rainsli
Copy link

Rainsli commented Aug 18, 2021

由于官方没写使用说明,我在这里发下。

1、首先将 com/roncoo/mybatis/generator/config/xml/ 目录下的两个 dtd 文件放到 resources 目录。

目录结构如下

输入图片说明

2、修改 com.roncoo.mybatis.generator.plugins.DaoPlugin.javacom.roncoo.mybatis.generator.internal.util.messages.Messages.java

变更 DaoPlugin 类中 Page 和 IdWorker 属性引用路径
private String pagePath = "com.roncoo.education.util.base.Page";
private String pageUtilPath = "com.roncoo.education.util.base.PageUtil";
private String idPath = "com.roncoo.education.util.tools.IdWorker";";

这三个类在均在 roncoo-education-util 项目中,需要在 pom.xml 对其进行引用,否则生成代码的引用路径是错的。你也可以将工具类的代码放在本地,生成之后再修改引用路径。

修改 DaoPlugin#validate 方法

此方法主要是根据 Generator.xml 动态配置生成的代码。因为上面工具类的路径写死了,所以动态配置这里需要注掉。你也可以放到 xml 里进行动态配置。

pagePath = properties.getProperty("pagePath");
pageUtilPath = properties.getProperty("pageUtilPath");
idPath = properties.getProperty("idPath");
变更 Messages 类中 BUNDLE_NAME 属性引用路径

改成加载自己当前包下的 messages.properties

private static final String BUNDLE_NAME = "com.roncoo.mybatis.generator.internal.util.messages.messages"; 

3、配置 Generator.xml

主要配置 roncoo 后期添加的一些 plugin。我把一些主要的贴在下面
<plugin type="com.roncoo.mybatis.generator.plugins.SerializablePlugin"/>
<plugin type="com.roncoo.mybatis.generator.plugins.ToStringPlugin"/>
<plugin type="com.roncoo.mybatis.generator.plugins.DaoPlugin">
    <!-- ServiceImpl方法的名称 -->
    <property name="enableInsertSelective" value="true"/>
    <property name="enableDeleteByExample" value="false"/>
    <!-- 支持count和page -->
    <property name="enableCount" value="true"/>
    <property name="enablePage" value="true"/>
    <!-- Service和ServiceImpl的目录和路径,其中targetProject必须填写否则执行报错 -->
    <property name="targetPackage" value="${target.package}.dao"/>
    <property name="targetProject" value="${target.project}"/>
    <property name="implementationPackage" value="${target.package}.dao.impl"/>
</plugin>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant