为什么在 rome-utils-1.15.0.jar 中没有主要清单属性?

问题描述

我正在尝试使用罗马 RSS 库。但是,当我去执行我的 jar 时,我得到了错误

我假设它与我的 build.gradle.kts 文件有关。我复制到这里

buildscript {
    repositories {
        maven("https://plugins.gradle.org/m2/")
        maven(url = "https://www.jitpack.io") {
            name = "jitpack"
        }
        flatDir {
            dirs("libs")
        }
    }
    dependencies {
    }
}

plugins {
    application
    kotlin("jvm") version "1.4.0"
    id("com.github.johnrengelman.shadow") version "6.1.0"
}

application {
    mainClassName = "io.ktor.server.netty.EngineMain"
}

repositories {
    mavenLocal()
    jcenter()
    mavenCentral()
    maven { url = uri("https://kotlin.bintray.com/ktor") }
    maven(url = "https://www.jitpack.io") {
        name = "jitpack"
    }
}

tasks {
    withType<KotlinCompile> {
        kotlinoptions.jvmTarget = "11"
    }
    named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
        archiveBaseName.set("freedom")
        archiveClassifier.set("")
        archiveVersion.set("1.1.0")
        manifest {
            attributes(mapOf("Main-Class" to application.mainClassName))
        }
    }
}

dependencies {
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
    implementation("io.ktor:ktor-server-netty:$ktor_version")
    implementation("com.rometools:rome:1.15.0")
    implementation("ch.qos.logback:logback-classic:$logback_version")
    implementation("io.ktor:ktor-client-core:$ktor_version")
    implementation("io.ktor:ktor-client-core-jvm:$ktor_version")
    implementation("io.ktor:ktor-gson:$ktor_version")
    implementation("io.ktor:ktor-client-apache:$ktor_version")
    implementation("io.ktor:ktor-html-builder:$ktor_version")
    implementation("com.github.chimbori:crux:2.2.0")
    implementation("org.jsoup:jsoup:1.13.1")
    implementation("io.lettuce:lettuce-core:6.0.1.RELEASE")
    implementation("org.jetbrains.exposed","exposed-core","0.28.1")
    implementation("org.jetbrains.exposed","exposed-dao","exposed-jdbc","0.28.1")
    implementation("com.google.firebase:firebase-admin:7.0.1")
    implementation("org.postgresql","postgresql","42.2.18")
    implementation("com.zaxxer:HikariCP:3.4.5")
    implementation("com.github.kittinunf.fuel:fuel:2.3.0")
    implementation("com.github.kittinunf.fuel:fuel-gson:2.3.0")
    testImplementation("io.ktor:ktor-server-tests:$ktor_version")
}

kotlin.sourceSets["main"].kotlin.srcDirs("src")
kotlin.sourceSets["test"].kotlin.srcDirs("test")

sourceSets["main"].resources.srcDirs("resources")
sourceSets["test"].resources.srcDirs("testresources")

我的应用程序在没有这个库的情况下构建得很好。但是,我需要使用这个特定的库。我已经尝试过类似问题中的步骤,但没有奏效。尝试执行我的程序时,我得到 no main manifest attribute,in rome-utils-1.15.0.jar

解决方法

问题在于 shadowJar 错误地构建了 Rome jar。这是shadowJar的github上必须要带的东西。

,

我遇到了同样的问题,我确定问题不在 build.gradle 文件中。

,

我相信你想要 mainClass 而不是 mainClassNameGradle user guide

试试吧

application {
    mainClass = "io.ktor.server.netty.EngineMain"
}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...