From a081ebec37347f6953daeb2fb7bb3ac8948727a8 Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Sun, 18 Jun 2023 17:52:09 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20e845902=20from=20https://gitee.com/Suom?= =?UTF-8?q?m/mybatis-flex/pulls/73=20doc:=20=E6=9B=B4=E6=96=B0=20APT=20?= =?UTF-8?q?=E6=96=87=E6=A1=A3=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E7=B1=BB=E4=B8=8D=E5=9C=A8=E5=90=8C=E4=B8=80=E4=B8=AA=E5=8C=85?= =?UTF-8?q?=E8=AF=B4=E6=98=8E=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/zh/others/apt.md | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/docs/zh/others/apt.md b/docs/zh/others/apt.md index 4d796f46..70b8a58d 100644 --- a/docs/zh/others/apt.md +++ b/docs/zh/others/apt.md @@ -132,14 +132,48 @@ processor.mappersPackage = com.your-package processor.baseMapperClass=com.domain.mapper.MyBaseMapper ``` +## 实体类不在一个包中 +有时候可能会遇到实体类不在同一个包中的情况,例如: + +```text +com.example.entityPackage1 + └─ Entity1 +com.example.entityPackage2 + └─ Entity2 +``` + +此时的辅助类会生成在对应的包下,例如: + +```text +com.example.entityPackage1.table + └─ Entity1TableDef +com.example.entityPackage2.table + └─ Entity2TableDef +``` + +但是,如果您设置了 `processor.allInTables=true` 的话,`Tables` 文件将会生成在最后一个包中,例如: + +```text +com.example.entityPackage2.table + └─ Tables +``` + +所以,如果您的实体类在多个包中,又指定了 `processor.allInTables=true` 选项,推荐设置 `Tables` 文件的位置,例如: + +```properties +processor.allInTables=true +processor.tablesPackage=com.example.entity.table +``` ## 和 Lombok、Mapstruct 整合 -在很多项目中,用到了 Lombok 帮我们减少代码编写,同时用到 Mapstruct 进行 bean 转换。使用到 Lombok 和 Mapstruct 时,其要求我们再 pom.xml 添加 `annotationProcessorPaths` 配置, +在很多项目中,用到了 Lombok 帮我们减少代码编写,同时用到 Mapstruct 进行 bean 转换。使用到 Lombok 和 Mapstruct 时,其要求我们再 +pom.xml 添加 `annotationProcessorPaths` 配置, 此时,我们也需要把 MyBatis-Flex 的 annotation 添加到 `annotationProcessorPaths` 配置里去,如下图所示: ```xml 24,25,26,27,28 + org.apache.maven.plugins maven-compiler-plugin