Files
tape-mybatis-generator-plugin/README.md
Jeremy Liang 00d8144a08 init commit
2026-02-04 03:23:08 +08:00

3.9 KiB

tape-mybatis-generator-plugin

MyBatis 代码生成插件

Uses

in pom.xml

<build>
    <finalName>application</finalName>
    <plugins>
        <!-- your other plugins -->
        <!-- add mybatis plugin -->
        <plugin>
            <groupId>org.mybatis.generator</groupId>
            <artifactId>mybatis-generator-maven-plugin</artifactId>
            <version>1.4.0</version>
            <configuration>
                <configurationFile>src/main/resources/mybatis.generator.xml</configurationFile>
                <overwrite>true</overwrite>
                <verbose>true</verbose>
            </configuration>
            <executions>
                <execution>
                    <id>Generate MyBatis Artifacts</id>
                    <phase>deploy</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                    <scope>runtime</scope>
                    <version>8.0.33</version>
                </dependency>
                <dependency>
                    <groupId>com.iqudoo.framework</groupId>
                    <artifactId>tape-mybaits-generator-plugin</artifactId>
                    <version>1.0-SNAPSHOT</version>
                    <systemPath>${project.basedir}/src/lib/tape-mybaits-generator-plugin-1.0-SNAPSHOT.jar</systemPath>
                    <scope>system</scope>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

in mybatis.generator.xml

<property name="viewKeyWords" value="VIEW_,V_"/>
<property name="targetProject" value="src/main/java"/>
<property name="modelPackage" value="com.iqudoo.platform.application.database.model"/>
<property name="mapperPackage" value="com.iqudoo.platform.application.database.mapper"/>
<property name="facadeRepositoryPackage" value="com.iqudoo.platform.application.facade.repository"/>
<property name="domainRepositoryPackage" value="com.iqudoo.platform.application.domain.repository"/>
<property name="facadeRepoviewPackage" value="com.iqudoo.platform.application.facade.repoview"/>
<property name="domainRepoviewPackage" value="com.iqudoo.platform.application.domain.repoview"/>

<plugin type="com.iqudoo.framework.mybatis.TapeMybatisGeneratorPlugin"/>
<plugin type="com.iqudoo.framework.mybatis.TapeRepositoryGeneratorPlugin"/>
<plugin type="com.iqudoo.framework.mybatis.TapeRepoviewGeneratorPlugin"/>

Table Template

DROP TABLE IF EXISTS `your_table_name`;
CREATE TABLE `your_table_name`  (
  `guid` bigint(0) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'GUID',
  -- ----------------------------
  -- add your table other table field
  -- ----------------------------
  `is_hidden` int(0) NOT NULL DEFAULT 0 COMMENT '隐藏标志',
  `is_delete` int(0) NOT NULL DEFAULT 0 COMMENT '删除标志',
  `delete_token` varchar(32) NULL DEFAULT '' COMMENT '删除令牌',
  `data_version` int(0) NOT NULL DEFAULT 0 COMMENT '数据版本',
  `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '更新时间',
  PRIMARY KEY (`guid`) USING BTREE
) ENGINE = InnoDB COMMENT = '你的表格备注' ROW_FORMAT = Dynamic;

in mybatis.generator.xml

<!-- your_table_name -->
<table tableName="your_table_name"
       domainObjectName="YourTableName"
       enableInsert="true"
       enableDeleteByPrimaryKey="true"
       enableUpdateByPrimaryKey="true"
       enableCountByExample="true"
       enableUpdateByExample="true"
       enableDeleteByExample="true"
       enableSelectByExample="true"
       selectByExampleQueryId="false">
    <property name="useActualColumnNames" value="false"/>
</table>