STEP 1. 在maven项目的pom.xml 添加mybatis-generator-maven-plugin 插件

pop.xml

<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.2</version>
</dependency>

<!-- mybatis generator 自动生成代码插件 -->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<configurationFile>${basedir}/src/main/resources/generator/generateConfig.xml</configurationFile>
<overwrite>true</overwrite>
<verbose>true</verbose>
</configuration>
</plugin>

STEP 2. 在maven项目下的src/main/resources 目录下建立名为 generatorConfig.xml的配置文件,作为mybatis-generator-maven-plugin 插件的执行目标,模板如下:

resources/generator/generateConfig.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
<generatorConfiguration>
<classPathEntry
location="D:\mysql-connector-java-5.1.26.jar" />
<context />
</table>
</context>
</generatorConfiguration>

STEP 3. 在Intellij IDEA添加一个“Run运行”选项,使用maven运行mybatis-generator-maven-plugin插件 :

IntelliJ IDEA mybatis-generator的使用

IntelliJ IDEA mybatis-generator的使用

 

IntelliJ IDEA mybatis-generator的使用

 

mybatis-generator:generate -e

IntelliJ IDEA mybatis-generator的使用

 

IntelliJ IDEA mybatis-generator的使用

 



相关文章:

  • 2021-09-06
  • 2022-01-15
  • 2021-05-27
猜你喜欢
  • 2021-06-21
  • 2021-07-14
  • 2021-08-14
  • 2021-09-12
  • 2022-12-23
  • 2021-11-14
相关资源
相似解决方案