Skip to content

higlowx/mybatis-generator-maven-plugin-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mybatis Generator Maven Plugin Extension

Restriction

  • You've already used official plugin in the target project will use this extension.
  • Property targetRuntime of official plugin must be MyBatis3.

Getting Started

  1. Add plugin dependencies into pom.xml of your project.
<build>
    <plugins>
        <plugin>
            <groupId>org.mybatis.generator</groupId>
            <artifactId>mybatis-generator-maven-plugin</artifactId>
            <version>1.4.1</version>
            <configuration>
                <configurationFile>
                    ${Your mybatis generator's configuration file}
                </configurationFile>
                <overwrite>true</overwrite>
                <verbose>true</verbose>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                    <version>5.1.5</version>
                </dependency>
                <dependency>
                    <groupId>com.higlowx</groupId>
                    <artifactId>mybatis-generator-maven-plugin-extension</artifactId>
                    <version>0.1.1-1.4.1</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>
  1. Configure your mybatis generator's configuration file, add <plugin> under <context> like using official plugin.
<context id="default" targetRuntime="MyBatis3">
    <plugin type="com.higlowx.mybatis.generator.plugin.SelectSelectivePlugin"/>
    <plugin type="com.higlowx.mybatis.generator.plugin.ModelColumnPlugin"/>
    <plugin type="com.higlowx.mybatis.generator.plugin.SelectOneByExamplePlugin"/>
</
  1. Run mybatis-generator:generate command.

If you configured all 3 plugins, method selectByExampleSelective(), selectOneByExample(), selectOneByExampleSelective(), selectByPrimaryKey() will be generated in java client and sql mapper.

  1. Test generated client and sql mapper.

Change Log

Usually, Releases Page reports main changes. You can also find more specific them in Change Log.

Acknowledging

This project derived from mybatis-generator-plugin supported for official maven plugin before v1.3.7. Unfortunately, for official newer version it's almost stagnant. I create this project therefore.