我想制作一个JAR来测试和部署我的应用程序,但它不工作,在本地它找不到清单文件中的主要属性,并在部署它启动,但我有这个错误:
java.lang.noclassdeffounderror: kotlinx/coroutines/slf4j/mdccontex
W
当我使用工件Jar在本地执行时,我找不到应用的MainClass,它重新命令我使用各种其他模块。
我试着修改我的gradle,清单,配置,但真的没有工作,这是令人沮丧的,它看起来很容易在一些youtube视频,但它就是不工作what I do to make the JAR
The classes i have access to when i try to select them这是我的成绩单
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.5.10"
application
kotlin("plugin.serialization") version "1.6.10"
}
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven(url = "https://jitpack.io")
}
val ktor_version: String by project
dependencies {
// Fix HTML issue on some responses
implementation("org.apache.commons:commons-text:1.10.0")
// Ktor dependencies
implementation("io.ktor:ktor-client-auth:$ktor_version")
implementation("io.ktor:ktor-client-core:$ktor_version")
implementation("io.ktor:ktor-client-cio:$ktor_version")
implementation("io.ktor:ktor-client-resources:$ktor_version")
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktor_version")
implementation("io.ktor:ktor-client-content-negotiation:$ktor_version")
implementation("io.ktor:ktor-client-logging:$ktor_version")
// Logging dependencies
implementation("ch.qos.logback:logback-classic:1.4.0")
implementation(kotlin("stdlib-jdk8"))
// Database
implementation ("mysql:mysql-connector-java:8.0.30")
implementation ("org.ktorm:ktorm-core:3.5.0")
implementation ("org.ktorm:ktorm-support-mysql:3.5.0")
}
application {
mainClass.set("MainKt")
}
val compileKotlin: KotlinCompile by tasks
compileKotlin.kotlinOptions {
jvmTarget = "1.8"
}
val compileTestKotlin: KotlinCompile by tasks
compileTestKotlin.kotlinOptions {
jvmTarget = "1.8"
}
tasks {
jar {
manifest {
attributes["Main-Class"] = application.mainClass
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
configurations.compileClasspath.get().forEach {
from(if (it.isDirectory) it else zipTree(it))
}
}
compileKotlin{
kotlinOptions.jvmTarget = "1.8"
}
}
先谢了
1条答案
按热度按时间flseospp1#
我的项目有很多问题和不一致,所以我开始了一个新的,并复制了所有的文件/包,花了一个小时重做所有的导入和插件,我的代码实际上需要运行,它终于工作,同样的评论不工作在以前的项目