# xbatis-generator-maven-plugin **Repository Path**: xbatis/xbatis-generator-maven-plugin ## Basic Information - **Project Name**: xbatis-generator-maven-plugin - **Description**: xbatis-generator maven-plugin - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 0 - **Created**: 2024-12-08 - **Last Updated**: 2025-04-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # xbatis-generator-maven-plugin ## xbatis maven代码生成插件 ## xbatis官网文档:http://xbatis.cn !!! ### 1. 快速开始 #### 1.1. 在pom中添加插件 ```xml cn.xbatis xbatis-generator-maven-plugin 1.1.3 com.mysql mysql-connector-j 9.1.0 ``` ### 2. 相关配置 - 两种配置方式 #### 2.1. 在外部xml文件中配置(推荐) ` 注意除configurationFile和skip配置外,其他配置参数可以放到外部xml文件中, xml文件root为:` ```xml ... ``` ##### 2.1.1. 配置maven插件 ```xml cn.xbatis xbatis-generator-maven-plugin 最新版本 com.mysql mysql-connector-j 9.1.0 src/main/resources/xbatis-generator.xml ``` ##### 2.1.2. 外部文件(xbatis-generator.xml)配置样例 ` xbatis-generator.xml 可由自己指定文件名,和上面的 configurationFile配置一样即可 ` ```xml trifolium true true xxx xxx jdbc:mysql://mysql.com:3306/db t_ t_admin t_admin_role com.company.app.test entity true true mapper false true mapper true true Mapper false false false false false ``` #### 2.2. 全部在pom文件中配置 ```xml cn.xbatis xbatis-generator-maven-plugin 最新版本 com.mysql mysql-connector-j 9.1.0 xxx xxx jdbc:mysql://mysql.com:3306/db false trifolium true t_ t_admin t_admin_role com.xxx.entity true true com.xxx.mapper false true src/main/resources/mappers true true Mapper false false false false false ``` ### 3. 运行maven命令 `mvn xbatis-generator:generate` 即可 ### 4. 更多配置,参考代码生成器xbatis-generator-core配置 > https://xbatis.cn/zh-CN/function/core/codeAutoCreate.html ### 5. 如需指定的xbatis-generator-core版本,请在插件plugin中添加依赖 ```xml cn.xbatis xbatis-generator-maven-plugin 最新版本 cn.xbatis xbatis-generator-core 指定版本 ``` ### 6. 注意事项 * 默认configurationFile是模块pom.xml文件目录同级下的xbatis-generator.xml文件 * 插件中 baseFilePath 默认为maven项目模块根目录(project.basedir) * 其中skip和configurationFile参数,必须在pom中配置,其他参数可委托到配置文件 * 默认javaPath 为 src/main/java (project.build.sourceDirectory) * 默认resourcePath 为 src/main/resources