docs(lesson6): drop accessor naming explanation per feedback
This commit is contained in:
1 parent
c089f2179e
commit
a3d4bc9429
1 file changed
-25
@@ -92,31 +92,6 @@ install(ContentNegotiation) {
|
||||
|
||||
如果不加这两个依赖,`body<List<Product>>()` 这类写法会失败(无法自动解析 JSON)。
|
||||
|
||||
### 4. 为什么是 `libs.ktor.client.content.negotiation`?
|
||||
这是 **Version Catalog(`libs.versions.toml`)自动生成 accessor** 的规则。
|
||||
|
||||
例如你在 TOML 里定义:
|
||||
|
||||
```toml
|
||||
ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
|
||||
```
|
||||
|
||||
Gradle 会把 `-` 转成 `.`,所以在 Kotlin DSL 里引用变成:
|
||||
|
||||
```kotlin
|
||||
implementation(libs.ktor.client.content.negotiation)
|
||||
```
|
||||
|
||||
同理:
|
||||
|
||||
- `ktor-client-core` -> `libs.ktor.client.core`
|
||||
- `ktor-serialization-kotlinx-json` -> `libs.ktor.serialization.kotlinx.json`
|
||||
|
||||
> 如果你“搜不到” `libs.ktor.client.content.negotiation`,先检查:
|
||||
> 1) `gradle/libs.versions.toml` 是否存在该 key;
|
||||
> 2) key 名字是否完全一致;
|
||||
> 3) 重新 Sync Gradle(IDE 才会刷新自动生成的 `libs` 访问器)。
|
||||
|
||||
---
|
||||
|
||||
## 四、共享模型(第2段:10分钟)
|
||||
|
||||
Reference in new issue
Block a user