Skip to content
This repository has been archived by the owner on Sep 30, 2022. It is now read-only.

自定义 Mybatis Generator 注释生成器,默认使用数据库注释作为生成 Java 注释,并支持附加注解。

License

Notifications You must be signed in to change notification settings

since1986/mybatis-comment-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mybatis-comment-generator


简介

这是用于 MyBatis Generator 中生成注释这一步骤的自定义生成器,默认将数据库注释作为 Java 注释,并支持在生成的 Java 代码中附加注解

示例

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
        PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
        "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
    <properties resource="package/to/your/data_source.properties"/>
    <context id="context_mysql" defaultModelType="flat" targetRuntime="MyBatis3">
        <property name="javaFileEncoding" value="UTF-8"/>

        <!-- CommentWithAnnotationCommentGenerator -->
        <commentGenerator type="io.github.since1986.mybatis.comment.generator.CommentWithAnnotationCommentGenerator">
            <property name="fieldAnnotationFullyQualifiedNames" value="one.your.customer.FieldAnnotationClass,another.your.customer.FieldAnnotationClass"/>
            <property name="classAnnotationFullyQualifiedNames" value="one.your.customer.ClassAnnotationClass,another.your.customer.ClassAnnotationClass"/>
        </commentGenerator>

        <jdbcConnection driverClass="${driverClass}" connectionURL="${connectionURL}" userId="${userId}" password="${password}">
            <!-- better keep this -->
            <property name="useInformationSchema" value="true"/>
        </jdbcConnection>

        <javaModelGenerator targetPackage="your.model" targetProject="/path/to/your/project/src/main/java">
        </javaModelGenerator>


        <sqlMapGenerator targetPackage="your.mapper" targetProject="src/main/resources">
        </sqlMapGenerator>


        <javaClientGenerator targetPackage="your.mapper" type="ANNOTATEDMAPPER" targetProject="src/main/java">
        </javaClientGenerator>

        <table tableName="your_table" domainObjectName="YourDomain">
        </table>
    </context>
</generatorConfiguration>

文章

实现过程,我写成了一篇文章,发布在了我的博客上。

About

自定义 Mybatis Generator 注释生成器,默认使用数据库注释作为生成 Java 注释,并支持附加注解。

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages