Automatically generate entity classes (method 2)


Maven extension tool plug-in provided by YMP framework

Step 1: Compile and install ymate-maven-extension extension tool

  • Download the extension tool source code (YMP framework Maven extension tool project address)

    执行命令:git clone https://git.oschina.net/suninformation/ymate-maven-extension.git
  • Compile and install to the local Maven repository

    执行命令: cd ymate-maven-extension
             mvn clean install

Step 2: Add ymate-maven-pluginplugin

   <plugin>
        <groupId>net.ymate.maven.plugins</groupId>
        <artifactId>ymate-maven-plugin</artifactId>
        <version>1.0-SNAPSHOT</version>
    </plugin>

to pom.xml. Step 3: Execute the plug-in to generate entities

Execute the command under the project root path:

mvn ymate:entity

Output content:

Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
[INFO] Scanning for projects...
[INFO] ......(此处省略若干字)
[INFO] --- ymate-maven-plugin:1.0-SNAPSHOT:entity (default-cli) @ ymp-examples-webapp ---
三月 25, 2016 12:25:07 上午 net.ymate.platform.core.YMP init
信息: 
__   ____  __ ____          ____  
\ \ / /  \/  |  _ \  __   _|___ \ 
 \ V /| |\/| | |_) | \ \ / / __) |
  | | | |  | |  __/   \ V / / __/ 
  |_| |_|  |_|_|       \_/ |_____|  Website: http://www.ymate.net/
三月 25, 2016 12:25:07 上午 net.ymate.platform.core.YMP init
信息: Initializing ymate-platform-core-2.0.0-GA build-20160324-2339 - debug:true
......(此处省略若干字)
信息: [show tables][][1][13ms]
Output file "/Users/suninformation/IdeaProjects/ymate-platform-examples/ymp-examples-webapp/src/main/java/net/ymate/platform/examples/model/User.java".
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.577s
[INFO] Finished at: Fri Mar 25 00:25:08 CST 2016
[INFO] Final Memory: 10M/163M
[INFO] ------------------------------------------------------------------------

The code generated through the plug-in is placed in src by default /main/java path, when the database table changes, directly execute the plug-in command to quickly update the data entity object. Isn’t it more convenient? You can try it! :p