首页 > 解决方案 > 基本身份验证应该在邮递员中响应 500(授权),但 401 Unathorized 可以正常工作。使用 ktor intellij mongodb

问题描述

java.lang.NoSuchMethodError: kotlinx.coroutines.channels.LinkedListChannel: method ()V not found

这是我的数据库.kt

private val client = KMongo.createClient().coroutine
private val database = client.getDatabase("PestaDanDagangDatabase")
private val users = database.getCollection()
private val posts = database.getCollection()
暂停乐趣 getPostsForUser(email: String) : List<> {
return posts.find(Post::members 包含电子邮件).toList()
}

我正在关注一些教程... getPostsForUser 返回 Post 数据类列表(它消失了.. 仍然需要学习使用 stackoverflow),即使我遵循相同的教程项目也在运行。我将返回更改为返回 posts.find(Post::members contains email).toString 并且函数返回 String 我的代码和我的教程结果都可以在邮递员中使用相同的响应 org.litote.kmongo.coroutine.CoroutineFindPublisher@44fc57b6( 44fc57b6 除外)。

我试图将返回更改为返回 posts.find(Post::members 包含电子邮件)和 Post 类型的函数返回类型 CoroutineFindPublisher,在邮递员中可以,但事件时间一直在滴答作响或运行。

标签: mongodbauthenticationpostmanktor

解决方案


我遇到了同样的问题,但对我来说,实现已更新到最新版本(如今天的 kmongo 4.4.0 & coroutines 1.6.0),错误是

kotlinx.coroutines.channels.LinkedListChannel: method 'void <init>() not found 

我意识到 .toList() 方法存在导入冲突

为了解决它,我只是简单地,而不是

return posts.find(Post::members contains email).toList()

用过的

return posts.find(Post::members contains email).publisher.KMongoToList()

作为进口

import org.litote.kmongo.coroutine.toList as KMongoToList

推荐阅读