doc: 展示 Gradle 的相关配置说明。

This commit is contained in:
Suomm 2023-08-09 16:51:29 +08:00
parent 2c7cb3f279
commit 6f2c13be3e
4 changed files with 27 additions and 17 deletions

View File

@ -46,6 +46,7 @@ export default defineConfig({
{text: 'MyBatis-Flex 是什么', link: '/zh/intro/what-is-mybatisflex'},
{text: '快速开始', link: '/zh/intro/getting-started'},
{text: 'Maven 依赖', link: '/zh/intro/maven'},
{text: 'Gradle 依赖', link: '/zh/intro/gradle'},
{text: '和同类框架「功能」对比', link: '/zh/intro/comparison'},
{text: '和同类框架「性能」对比', link: '/zh/intro/benchmark'},
{text: '使用 Mybatis 原生功能', link: '/zh/intro/use-mybatis-native'},
@ -100,6 +101,7 @@ export default defineConfig({
items: [
{text: '代码生成器', link: '/zh/others/codegen'},
{text: 'APT 设置', link: '/zh/others/apt'},
{text: 'KAPT 设置', link: '/zh/others/kapt'},
]
}
],

View File

@ -1,14 +1,14 @@
# Gradle 依赖
> 以下的 xml gradle 依赖示例中,可能并非最新的 MyBatis-Flex 版本,请自行查看最新版本,并修改版本号。
>
> 建议配置 annotationProcessor那么可以省略mybatis-flex-processor的依赖
>
> 以下的 gradle 依赖示例中,可能并非最新的 MyBatis-Flex 版本,请自行查看最新版本,并修改版本号。
> 建议配置 annotationProcessor那么可以省略 mybatis-flex-processor 的依赖
1、只用到了 MyBatis没用到 Spring 的场景:
**【Kotlin】**
```kotlin
dependencies {
implementation("com.mybatis-flex:mybatis-flex-core:1.5.6")
@ -17,6 +17,7 @@ dependencies {
```
**【Groovy】**
```groovy
dependencies {
implementation 'com.mybatis-flex:mybatis-flex-core:1.5.6'
@ -41,9 +42,11 @@ dependencies {
compileOnly 'com.mybatis-flex:mybatis-flex-processor:1.5.6'
}
```
3、用到了 Spring Boot 的场景
**【Kotlin】**
```kotlin
dependencies {
implementation("com.mybatis-flex:mybatis-flex-spring-boot-starter:1.5.6")
@ -52,6 +55,7 @@ dependencies {
```
**【Groovy】**
```groovy
dependencies {
implementation 'com.mybatis-flex:mybatis-flex-spring-boot-starter:1.5.6'
@ -59,15 +63,16 @@ dependencies {
}
```
4. 配置 annotationProcessor
4配置 annotationProcessor
`mybatis-flex-processor`提供APT服务可以配置到annotationProcessorPaths配置后无需在依赖中声明`mybatis-flex-processor`依赖。
`mybatis-flex-processor` 提供 APT 服务,可以配置到 annotationProcessorPaths,配置后,无需在依赖中声明 `mybatis-flex-processor` 依赖。
参考:[APT 设置-和 Lombok、Mapstruct 整合](../others/apt.md)
参考:[APT 设置-和 Lombok、Mapstruct 整合](../others/apt.md)
> 在Kotlin中使用时请参考[在Kotlin中使用注解处理器](../kotlin/kapt.md)
> 在 Kotlin 中使用时,请参考[在 Kotlin 中使用注解处理器](../others/kapt.md)
**【Kotlin】**
```kotlin
dependencies {
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor:1.5.6")
@ -75,6 +80,7 @@ dependencies {
```
**【Groovy】**
```groovy
dependencies {
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor:1.5.6'

View File

@ -60,7 +60,7 @@
参考:[APT 设置-和 Lombok、Mapstruct 整合](../others/apt.md)
> 在Kotlin中使用时请参考[在Kotlin中使用注解处理器](../kotlin/kapt.md)
> 在Kotlin中使用时请参考[在Kotlin中使用注解处理器](../others/kapt.md)
```xml
<plugin>

View File

@ -1,11 +1,10 @@
# 在Kotlin中使用注解处理器
# 在 Kotlin 中使用注解处理器
> 在Kotlin中想要使`@Table`等注解生效十分简单。只需要使用kapt即可。
>
> 在 Kotlin 中想要使 `@Table` 等注解生效十分简单。只需要使用 KAPT 即可。
## 在Gradle中使用
## 在 Gradle 中使用
1. 应用Gradle插件kotlin-kapt
1、应用 Gradle 插件:`kotlin-kapt`
**【Kotlin】**
@ -23,7 +22,9 @@ plugins {
}
```
2. 在 dependencies 块中使用 kapt 配置添加相应的依赖项
2、在 dependencies 块中使用 KAPT 配置添加相应的依赖项
**【Kotlin】**
```kotlin
@ -39,7 +40,8 @@ dependencies {
}
```
## 在Maven中使用
## 在 Maven 中使用
在 compile 之前在 kotlin-maven-plugin 中添加 kapt 目标的执行:
```xml
@ -60,4 +62,4 @@ dependencies {
</execution>
```
> 关于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)。