update docs

This commit is contained in:
开源海哥 2023-04-24 11:50:21 +08:00
parent 0318044ae0
commit fd984e1c37
2 changed files with 23 additions and 19 deletions

View File

@ -6,13 +6,6 @@ Mybatis-Flex 使用了 APTAnnotation 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 整合

View File

@ -29,7 +29,7 @@ CREATE TABLE IF NOT EXISTS `tb_account`
</dependency>
```
**第 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<Account> {
}
```
**第 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)。
## 更多示例