mongodb - 基本身份验证应该在邮递员中响应 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,在邮递员中可以,但事件时间一直在滴答作响或运行。
解决方案
我遇到了同样的问题,但对我来说,实现已更新到最新版本(如今天的 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
推荐阅读
- android - 文本大小 AppBar / NavBar 辅助功能
- java - 发送电子邮件后如何敬酒?
- spring - 选择带有弹簧数据的自引用表到新对象中
- react-native - 从导航标题返回屏幕时出错:未定义不是对象(评估“this.props.navigation.navigate”)
- python - Sympy 符号微分
- azure - PatchOrchestrationApplicationType 1.2.2 - FABRIC_E_FILE_NOT_FOUND:在商店中找不到应用程序清单文件“ApplicationManifest.xml”
- android - 与父底部对齐的视图被隐藏,同时在协调器布局中包含相对布局
- java - 无法将源从目标复制到包的目标
- c# - 剃刀生成器在剃刀视图中添加空注释行
- wpf - scichart3d几何对象选择是不可能的吗?