In the code generated using idea Mybatis.generator, there is a lot of repetition of the generated code,
Although the code is generated, we should not allow duplicate code to appear because the code is later manually maintained.
For build timestamp annotations, example types, XML, and so on, most of them can be configured through XML, so that they are not generated.
However, it is not realistic to have some code styles that conform to their coding habits to be generated by configuration. In this case, I can be resolved by extending the Mybatis.generator plugin.
Plug-in writing instructions online there are many, listed a few of their own seen
Http://generator.sturgeon.mopaas.com/reference/extending.html
http://blog.geyuxu.com/2015/11/02/java/Add Mybatis-generator page plug-in in Intellij/
Intellij automatic generation of MyBatis code using Mybatis-generator in Idea 14
MyBatis Generator generate MyBatis code with pagination
Many netizens have provided the various plugins to serialize and page the DTO, and after generating the plugin, how do we check into idea?
Step 1. Add the plugins we need, for example: Serializableplugin, Basemappergeneratorplugin, and we'll build a jar package in the project alone
Step 2. In our actual project, the jar packages generated in Step1 are placed in our local MAVEN repository
The specific steps can refer to this Bo friend's operating instructions, the purpose is that we need to step1 in the build jar in the Mybatis.generator plug-in configuration, directly from the local storage can find the change file.
Command:
install:install-file -Dfile=/Users/geyuxu/Desktop/pagination-0.1.jar -DgroupId=com.geyuxu.utils -DartifactId=pagination -Dversion=0.1 -Dpackaging=jar
Step 3: This step is to configure our Org.mybatis.generator plugin and tell him to go to the jar to find the plugin we provided to him.
The configuration is as follows (if you do not configure this step, you may see the following exception:
caused by:org.apache.maven.plugin.PluginExecutionException:Execution default-cli of goal Org.mybatis.generator: Mybatis-generator-maven-plugin:1.3.2:generate Failed:cannot Instantiate object of type com.)
(PS: If you follow the above steps, the above exception will still occur, those manually delete the local maven storage in the jar file deleted, the project references are also deleted, re-generated jar re-reference)
<!--Mybatis-generator-maven-plugin Plug-ins to complete MyBatis model and mapper files - <plugin> <groupId>Org.mybatis.generator</groupId> <Artifactid>Mybatis-generator-maven-plugin</Artifactid> <version>1.3.2</version> <Configuration> <!--mybatis automatically generate rule profile address - <ConfigurationFile>Src/main/resources/mybatis/generatorconfig.xml</ConfigurationFile> <verbose>True</verbose> <Overwrite>True</Overwrite> </Configuration> <Dependencies> <Dependency> <Artifactid>Xxxx-xxx-utils</Artifactid> <groupId>Xx.xxxx.xxx.xxx</groupId> <version>1.0</version> </Dependency> </Dependencies> </plugin>
Remember it once idea mybatis.generator custom extension