diff --git a/docs/assets/images/kapt1.png b/docs/assets/images/kapt1.png new file mode 100644 index 00000000..60cf9949 Binary files /dev/null and b/docs/assets/images/kapt1.png differ diff --git a/docs/zh/kotlin/kapt.md b/docs/zh/kotlin/kapt.md index 454d082b..174511cf 100644 --- a/docs/zh/kotlin/kapt.md +++ b/docs/zh/kotlin/kapt.md @@ -19,12 +19,12 @@ ```groovy plugins { - id "org.jetbrains.kotlin.kapt" version "1.9.0" + id 'org.jetbrains.kotlin.kapt' version '1.9.0' } ``` 2. 在 dependencies 块中使用 kapt 配置添加相应的依赖项 -**【Kotlin】** + **【Kotlin】** ```kotlin dependencies { @@ -33,6 +33,7 @@ dependencies { ``` **【Groovy】** + ```groovy dependencies { kapt 'org.springframework.boot:spring-boot-configuration-processor:1.5.6' @@ -40,9 +41,11 @@ dependencies { ``` ## 在Maven中使用 -在 compile 之前在 kotlin-maven-plugin 中添加 kapt 目标的执行: + +1. 将以下kapt配置插入指定位置。 ```xml + kapt @@ -60,4 +63,45 @@ dependencies { ``` -> 关于Kapt更详细的说明,请看[Kotlin官网说明](https://book.kotlincn.net/text/kapt.html),或[Kotlin语言中文站](https://www.kotlincn.net/docs/reference/kapt.html)。 +你需要使kapt在compile前工作。将其插入到`kotlin-maven-plugin`中的compile前, +然后将compile的时机改为`process-sources` + +```xml + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + + + compile + + process-sources + + compile + + + + test-compile + test-compile + + test-compile + + + + +``` +2. 令kapt在构建前运行 + +以idea举例 +1. 点击maven图标 +2. 找到对应项目 +3. 点击插件 +4. 点击kotlin +5. 右击kotlin:kapt,在选项中点击"**构建前执行**",以让kapt能够正确的生成代码。 +![](../../assets/images/kapt1.png) + + +> 关于Kapt更详细的说明,请看[Kotlin官网说明](https://book.kotlincn.net/text/kapt.html) +> ,或[Kotlin语言中文站](https://www.kotlincn.net/docs/reference/kapt.html)。