如何在类路径中包含kotlin-reflect.jar

问题描述

我正在尝试致电someObject::class.annotations,但在运行时出现错误

Exception in thread "main" kotlin.jvm.KotlinReflectionNotSupportedError: Kotlin reflection implementation is not found at runtime. Make sure you have kotlin-reflect.jar in the classpath

我尝试以我在build.gradle.kts文件中包含反射库的形式,以StackOverflow上建议的任何不同形式使用该反射库,但仍然出现此错误

在gradle文件中的dependencies块中,我尝试过:

api(kotlin("reflect"))
runtimeOnly(kotlin("reflect"))
implementation(kotlin("reflect"))
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.4.0")

但这些方法都不能解决问题,也没有有关如何在类路径中包含此jar的官方文档。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)