gpt4 book ai didi

kotlin - 为什么更新Gradle break log4j导入?

转载 作者:行者123 更新时间:2023-12-02 13:06:52 33 4
gpt4 key购买 nike

我正在尝试更新到Kotlin 1.4。在我的build.gradle文件中,我具有以下内容:

buildscript {
allprojects {
ext {
kotlin_version = "1.3.70"
ktor_version = "1.2.2"
junit_version = "5.4.2"
log4j_version = "2.11.2"
jackson_version = "2.9.9"
kafka_version = "2.3.0"
}
}
repositories {
maven {
url 'https://smartward.jfrog.io/smartward/gradle-dev'
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
}


dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.9.7"
}
}
后来:
        implementation(
"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version",
"org.jetbrains.kotlin:kotlin-reflect:$kotlin_version",
"org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version",
"org.apache.logging.log4j:log4j-api:$log4j_version",
// For JSON mapping
"com.fasterxml.jackson.module:jackson-module-kotlin:$jackson_version",
"com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version",
"com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:$jackson_version",
"com.natpryce:konfig:1.6.10.0",
"org.apache.kafka:kafka-clients:$kafka_version",

"io.ktor:ktor-server-netty:$ktor_version",
"io.ktor:ktor-locations:$ktor_version",
"io.ktor:ktor-jackson:$ktor_version",
"io.ktor:ktor-client-core:$ktor_version",
"io.ktor:ktor-client-apache:$ktor_version",
"io.ktor:ktor-client-json:$ktor_version"
)
我的第一步是将kotlin_version更改为“1.4.0”。运行构建脚本时,我被告知Gradle也需要更新。我这样做了,更改了gradle-wrapper.properties文件(下面的差异):
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.3-all.zip
现在这意味着我的某些log4j导入不再起作用。即:
import org.apache.logging.log4j.core.Logger
import org.apache.logging.log4j.core.config.Configurator
我试图还原到Kotlin 1.3.70,而没有还原Gradle更新,并且问题仍然存在,所以我怀疑Gradle或我的构建脚本有问题,但是我不确定为什么或如何修复它。我还尝试过将Gradle 6.6与org.jfrog.buildinfo:build-info-extractor-gradle的4.17.1版本一起使用,但是问题仍然存在。

最佳答案

按照official documentation of Log4j,您需要同时链接到log4j-apilog4j-core才能正确使用该软件包。

关于kotlin - 为什么更新Gradle break log4j导入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63570680/

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