diff --git a/docs/zh/apt.md b/docs/zh/apt.md index 17e313f8..aee60c44 100644 --- a/docs/zh/apt.md +++ b/docs/zh/apt.md @@ -6,13 +6,6 @@ Mybatis-Flex 使用了 APT(Annotation Processing Tool)技术,在项目编 ![](../assets/images/build_idea.png) -## 关闭 APT 功能 - -在项目的 resources 目录下添加 `mybatis-flex.properties` 配置文件,配置内容如下: - -```properties -processor.enable = false -``` ## APT 代码生成路径 @@ -42,6 +35,18 @@ processor.tablesPackage = com.your-package processor.tablesClassName = your-class-name ``` + +## APT 开启 Mapper 生成 + +从 v1.1.9 开始, APT 的 Mapper 功能是关闭的,若需要开启 Mapper 的自动生成功能,需要添加一下配置。 + +```properties +processor.mappersGenerateEnable = true +``` + +以上的配置,会关闭整个项目的 APT 生成,若我们只想关闭某一个 Entity 的 APT 生成,那么可以通过配置注解 `@Table(mapperGenerateEnable = false)` 进行关闭。 + + ## APT 生成的 Mapper 包名 默认情况下, APT 生成的 Mapper 类名为 "***Mapper",而包名为 entity 的包添加上 ".mapper",假设 Account.java @@ -63,15 +68,6 @@ processor.baseMapperClass=com.domain.mapper.MyBaseMapper ``` -## APT 关闭 Mapper 生成 - -在某些情况下,我们可能需要手写 Mapper,不需要 APT 生成,可以通过如下配置关闭 APT 的生成功能。 - -```properties -processor.mappersGenerateEnable = false -``` - -以上的配置,会关闭整个项目的 APT 生成,若我们只想关闭某一个 Entity 的 APT 生成,那么可以通过配置注解 `@Table(mapperGenerateEnable = false)` 进行关闭。 ## 和 Lombok、Mapstruct 整合 diff --git a/docs/zh/getting-started.md b/docs/zh/getting-started.md index bdc8fe2d..2c3d5207 100644 --- a/docs/zh/getting-started.md +++ b/docs/zh/getting-started.md @@ -29,7 +29,7 @@ CREATE TABLE IF NOT EXISTS `tb_account` ``` -**第 3 步:编写实体类** +**第 3 步:编写实体类和 Mapper** > 这部分可以使用 Mybatis-Flex 的代码生成器来生成实体类哟,功能非常强大的。详情进入:[代码生成器章节](./codegen.md) 了解。 @@ -49,6 +49,15 @@ public class Account { - 使用 `@Table("tb_account")` 设置实体类与表名的映射关系 - 使用 `@Id(keyType = KeyType.Auto)` 标识主键为自增 +Mapper +```java +public interface AccountMapper extends BaseMapper { + +} +``` + + + **第 4 步:通过 main 方法开始使用(无 Spring 的场景)** ```java @@ -88,8 +97,7 @@ public class HelloWorld { } ``` -> 以上的示例中, `AccountMapper.class` 和 `ACCOUNT` 为 Mybatis-Flex 通过 APT 自动生成,无需手动编码。 -> 我们也可以关闭 mapper 的自动生成功能,手动编写 AccountMapper,更多查看 [APT 文档](./apt)。 +> 以上的示例中, `ACCOUNT` 为 Mybatis-Flex 通过 APT 自动生成,无需手动编码。更多查看 [APT 文档](./apt)。 ## 更多示例