IDEA|IDEA 中使用 MyBatis-generator 自动生成代码

一、创建项目 ??首先得用idea创建一个maven项目。
二、修改pom文件 ??在 pom 文件中添加依赖:

org.mybatis.generator mybatis-generator-core 1.3.2

??在 pom 文件中添加 mybatis-generator-maven-plugin 插件:
org.mybatis.generator mybatis-generator-maven-plugin 1.3.2 src/main/resources/mybatis-generator.xml true true

三、添加配置文件 ??在 src/main/resources 目录下,添加文件 mybatis-generator.xml :

四、运行 ??点击idea右边的 Maven ,然后找到我用红色框框起来的部分,双击运行。
IDEA|IDEA 中使用 MyBatis-generator 自动生成代码
文章图片
maven插件运行 五、结果 ??当你看到控制台输出 BUILD SUCCESS ,则表明已经自动生成成功了。
F:\qq\java\jdk1.8\bin\java.exe -Dmaven.multiModuleProjectDirectory=F:\qq\trademarket "-Dmaven.home=F:\IntelliJ IDEA 2019.1.3\plugins\maven\lib\maven3" "-Dclassworlds.conf=F:\IntelliJ IDEA 2019.1.3\plugins\maven\lib\maven3\bin\m2.conf" "-javaagent:F:\IntelliJ IDEA 2019.1.3\lib\idea_rt.jar=52561:F:\IntelliJ IDEA 2019.1.3\bin" -Dfile.encoding=UTF-8 -classpath "F:\IntelliJ IDEA 2019.1.3\plugins\maven\lib\maven3\boot\plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version2019.1.3 org.mybatis.generator:mybatis-generator-maven-plugin:1.3.2:generate [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building trademarket-core 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- mybatis-generator-maven-plugin:1.3.2:generate (default-cli) @ trademarket-core --- [INFO] Connecting to the Database Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. [INFO] Introspecting table tbl_bill log4j:WARN No appenders could be found for logger (org.mybatis.generator.internal.db.DatabaseIntrospector). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. [INFO] Introspecting table tbl_user [INFO] Generating Example class for table tbl_user [INFO] Generating Record class for table tbl_user [INFO] Generating Mapper Interface for table tbl_user [INFO] Generating SQL Map for table tbl_user [INFO] Saving file UserMapper.xml [INFO] Saving file UserExample.java [INFO] Saving file User.java [INFO] Saving file UserMapper.java [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.948 s [INFO] Finished at: 2019-12-27T14:30:05+08:00 [INFO] Final Memory: 15M/203M [INFO] ------------------------------------------------------------------------Process finished with exit code 0

【IDEA|IDEA 中使用 MyBatis-generator 自动生成代码】如遇到什么问题,可以在下方留言区进行讨论。如果觉得本文写的还可以,不妨点个赞 收藏以下吧~

    推荐阅读