RT

build.gradle.kts

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("jvm") version "1.6.0" application java } group = "io.github.xxx" version = "1.0-SNAPSHOT" repositories { mavenLocal() mavenCentral() } dependencies { //mirai val miraiVersion = "2.9.0-RC" api("net.mamoe", "mirai-core-api", miraiVersion) implementation("net.mamoe", "mirai-core", miraiVersion) implementation("org.jetbrains.kotlin", "kotlin-reflect") implementation("org.jetbrains.kotlin", "kotlin-stdlib-jdk8") //logging implementation("ch.qos.logback:logback-core:1.3.0-alpha10") implementation("ch.qos.logback:logback-classic:1.3.0-alpha10") implementation("org.slf4j:slf4j-api:2.0.0-alpha5") implementation("io.github.microutils", "kotlin-logging-jvm", "2.0.6") implementation("com.fasterxml.jackson.core", "jackson-databind", "2.13.0") implementation("com.fasterxml.jackson.module", "jackson-module-kotlin", "2.13.0") implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.0") runtimeOnly("com.fasterxml.jackson.module:jackson-modules-java8:2.13.0") testImplementation("org.jetbrains.kotlin:kotlin-test:1.6.0") } tasks.withType<KotlinCompile>() { kotlinOptions.jvmTarget = "17" // kotlinOptions.freeCompilerArgs = listOf("-Dmirai.no-desktop") } val main = "io.github.xxx.MainKt" application { mainClass.set(main) } tasks.jar { manifest { attributes(mapOf( "Main-Class" to main, "Implementation-Title" to project.name, "Implementation-Version" to project.version )) } configurations["compileClasspath"].forEach { file: File -> from(zipTree(file.absoluteFile)) } duplicatesStrategy = DuplicatesStrategy.INCLUDE }

error:

Exception in thread "main" java.lang.NoClassDefFoundError: net/mamoe/mirai/utils/ServicesKt at net.mamoe.mirai.utils.MiraiLogger$Factory$INSTANCE.<init>(MiraiLogger.kt:88) at net.mamoe.mirai.utils.MiraiLogger$Factory$INSTANCE.<clinit>(MiraiLogger.kt) at net.mamoe.mirai.utils.MiraiLogger$Factory.<clinit>(MiraiLogger.kt) at net.mamoe.mirai.utils.WindowHelperJvm.<clinit>(SwingSolver.kt:135) at net.mamoe.mirai.utils.LoginSolver.<clinit>(LoginSolver.jvm.kt:92) at net.mamoe.mirai.utils.BotConfiguration.<init>(BotConfiguration.kt:231) at net.mamoe.mirai.utils.BotConfiguration.<clinit>(BotConfiguration.kt:624) at io.github.xxx.MainKt.<clinit>(Main.kt:110) Caused by: java.lang.ClassNotFoundException: net.mamoe.mirai.utils.ServicesKt at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ... 8 more

我在打包的jar文件中也没有找到该class