本文主要记录Intellij idea使用Mybatis - generator如何通过配置自动生成相关代码的过程。
1 pom.xml
本次在MAVEN中使用 mybatis-generator-maven-plugin插件来完成这个功能,maven配置如下:
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.6</version>
<configuration>
<configurationFile>
# 此处为generatorConfig.xml配置文件的路径
${basedir}/src/main/resources/generator/generatorConfig.xml
</configurationFile>
<overwrite>true</overwrite>
<verbose>true</verbose>
</configuration>
<dependencies>
<dependency>
<groupId>sqljdbc</groupId>
<artifactId>sqljdbc</artifactId>
<version>4</version>
<!-- system作用域的依赖项不会从maven仓库抓,而是从本地系统文件拿,一定要配合systemPath使用 -->

本文介绍了如何在IntelliJ IDEA中利用MyBatis Generator插件,通过配置pom.xml和generatorConfig.xml文件,自动生成MyBatis的XML映射文件、实体类以及DAO接口。详细步骤包括配置Maven插件、定义数据库连接、指定生成代码的目标位置以及运行生成命令。
最低0.47元/天 解锁文章
4690

被折叠的 条评论
为什么被折叠?



