mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 09:08:24 +08:00
style: 优化 KAPT 文档。
This commit is contained in:
parent
3f412653bd
commit
6a4fa7ad8a
@ -1,11 +1,10 @@
|
|||||||
# 在 Kotlin 中使用注解处理器
|
# 在 Kotlin 中使用注解处理器
|
||||||
|
|
||||||
> 在Kotlin中想要使`@Table`等注解生效十分简单。只需要使用kapt即可。
|
> 在 Kotlin 中想要使 `@Table` 等注解生效十分简单。只需要使用 KAPT 即可。
|
||||||
>
|
|
||||||
|
|
||||||
## 在 Gradle 中使用
|
## 在 Gradle 中使用
|
||||||
|
|
||||||
1. 应用Gradle插件:kotlin-kapt
|
1、应用 Gradle 插件:`kotlin-kapt`
|
||||||
|
|
||||||
**【Kotlin】**
|
**【Kotlin】**
|
||||||
|
|
||||||
@ -23,7 +22,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
2. 在 dependencies 块中使用 kapt 配置添加相应的依赖项
|
2、在 dependencies 块中使用 kapt 配置添加相应的依赖项
|
||||||
|
|
||||||
**【Kotlin】**
|
**【Kotlin】**
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
@ -42,10 +42,9 @@ dependencies {
|
|||||||
|
|
||||||
## 在 Maven 中使用
|
## 在 Maven 中使用
|
||||||
|
|
||||||
1. 将以下kapt配置插入指定位置。
|
1、 将以下kapt配置插入指定位置。
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
|
|
||||||
<execution>
|
<execution>
|
||||||
<id>kapt</id>
|
<id>kapt</id>
|
||||||
<goals>
|
<goals>
|
||||||
@ -63,8 +62,7 @@ dependencies {
|
|||||||
</execution>
|
</execution>
|
||||||
```
|
```
|
||||||
|
|
||||||
你需要使kapt在compile前工作。将其插入到`kotlin-maven-plugin`中的compile前,
|
你需要使 KAPT 在 compile 前工作,将其插入到 `kotlin-maven-plugin` 中的 compile 前,然后将 compile 的时机改为 `process-sources`
|
||||||
然后将compile的时机改为`process-sources`
|
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -73,7 +71,6 @@ dependencies {
|
|||||||
<version>${kotlin.version}</version>
|
<version>${kotlin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<!--上述代码需插入到此处,compile前-->
|
<!--上述代码需插入到此处,compile前-->
|
||||||
|
|
||||||
<execution>
|
<execution>
|
||||||
<id>compile</id>
|
<id>compile</id>
|
||||||
<!--将此处的phase改为process-sources-->
|
<!--将此处的phase改为process-sources-->
|
||||||
@ -92,16 +89,17 @@ dependencies {
|
|||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
```
|
```
|
||||||
2. 令kapt在构建前运行
|
|
||||||
|
|
||||||
以idea举例
|
2、 令 KAPT 在构建前运行
|
||||||
1. 点击maven图标
|
|
||||||
|
以 IDEA 举例:
|
||||||
|
|
||||||
|
1. 点击 Maven 图标
|
||||||
2. 找到对应项目
|
2. 找到对应项目
|
||||||
3. 点击插件
|
3. 点击插件
|
||||||
4. 点击 kotlin
|
4. 点击 kotlin
|
||||||
5. 右击kotlin:kapt,在选项中点击"**构建前执行**",以让kapt能够正确的生成代码。
|
5. 右击 kotlin:kapt,在选项中点击“**构建前执行**”,以让 KAPT 能够正确的生成代码。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
> 关于 KAPT 更详细的说明,请看[Kotlin官网说明](https://book.kotlincn.net/text/kapt.html),或[Kotlin语言中文站](https://www.kotlincn.net/docs/reference/kapt.html)。
|
||||||
> 关于Kapt更详细的说明,请看[Kotlin官网说明](https://book.kotlincn.net/text/kapt.html)
|
|
||||||
> ,或[Kotlin语言中文站](https://www.kotlincn.net/docs/reference/kapt.html)。
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user