gpt4 book ai didi

java - mainClassName的etter : String' is deprecated.在Java中已弃用

转载 作者:行者123 更新时间:2023-12-03 04:53:56 25 4
gpt4 key购买 nike

我有一个用Kotlin和Gradle编写的vert.x Web应用程序作为构建工具。该网络应用已使用https://start.vertx.io/生成。
build.gradle.kts中显示:
enter image description here
mainClassName已被弃用。build.gradle.kts文件的内容:

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.api.tasks.testing.logging.TestLogEvent.*
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin ("jvm") version "1.4.10"
application
id("com.github.johnrengelman.shadow") version "5.2.0"
id("org.flywaydb.flyway") version "7.1.1"
}

group = "io.databaker"
version = "1.0.0-SNAPSHOT"

repositories {
mavenCentral()
jcenter()
}

val kotlinVersion = "1.4.10"
val vertxVersion = "4.0.0.CR1"
val junitJupiterVersion = "5.6.0"

val mainVerticleName = "io.databaker.MainVerticle"
val watchForChange = "src/**/*"
val doOnChange = "./gradlew classes"
val launcherClassName = "io.vertx.core.Launcher"

application {
mainClassName = launcherClassName
}

dependencies {
implementation("io.vertx:vertx-auth-jwt:$vertxVersion")
implementation("io.vertx:vertx-web:$vertxVersion")
implementation("io.vertx:vertx-pg-client:$vertxVersion")
implementation("io.vertx:vertx-lang-kotlin-coroutines:$vertxVersion")
implementation("io.vertx:vertx-json-schema:$vertxVersion")
implementation("io.vertx:vertx-lang-kotlin:$vertxVersion")
implementation(kotlin("stdlib-jdk8"))
testImplementation("io.vertx:vertx-junit5:$vertxVersion")
testImplementation("org.junit.jupiter:junit-jupiter:$junitJupiterVersion")
}

val compileKotlin: KotlinCompile by tasks
compileKotlin.kotlinOptions.jvmTarget = "11"

tasks.withType<ShadowJar> {
archiveClassifier.set("fat")
manifest {
attributes(mapOf("Main-Verticle" to mainVerticleName))
}
mergeServiceFiles {
include("META-INF/services/io.vertx.core.spi.VerticleFactory")
}
}

tasks.withType<Test> {
useJUnitPlatform()
testLogging {
events = setOf(PASSED, SKIPPED, FAILED)
}
}

tasks.withType<JavaExec> {
args = listOf("run", mainVerticleName, "--redeploy=$watchForChange", "--launcher-class=$launcherClassName", "--on-redeploy=$doOnChange")
}
我应该通过什么替换 mainClassName

最佳答案

看来执行此操作的最新方法是:

application {
mainClass.set(launcherClassName)
}

关于java - mainClassName的etter : String' is deprecated.在Java中已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64749528/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com