获取“未能捕获任务的输入文件快照”:compilejava“

mrzz3bfm  于 2021-06-06  发布在  Kafka
关注(0)|答案(1)|浏览(338)

我正在尝试为apachekafka poc设置一个简单的gradle项目。请建议如何解决这个问题。
生成时跟踪堆栈

Root cause: org.gradle.internal.resolve.ArtifactNotFoundException: Could not find jms.jar (javax.jms:jms:1.1).
Searched in the following locations:
    https://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.jar

这是用于该项目的gradle文件

apply plugin: 'java-library'

repositories {

     mavenCentral()
}

dependencies {
    api 'org.apache.commons:commons-math3:3.6.1'

    implementation 'com.google.guava:guava:23.0'

    testImplementation 'junit:junit:4.12'

    compile(group: 'org.apache.kafka', name: 'kafka_2.10', version: '0.8.0') 

    compile 'org.apache.kafka:kafka-clients:0.10.2.0'
}
yhuiod9q

yhuiod9q1#

问题来自于属于zookeeper传递库的传递库log4j-1.2.15:

+--- org.apache.kafka:kafka_2.10:0.8.0
|    +--- org.apache.zookeeper:zookeeper:3.3.4
|    |    +--- log4j:log4j:1.2.15
|    |    |    +--- javax.mail:mail:1.4
|    |    |    |    \--- javax.activation:activation:1.1
|    |    |    +--- javax.jms:jms:1.1
|    |    |    +--- com.sun.jdmk:jmxtools:1.2.1
|    |    |    \--- com.sun.jmx:jmxri:1.2.1
|    |    \--- jline:jline:0.9.94
|    |         \--- junit:junit:3.8.1

这个log4j版本依赖于其他不在maven central repository上托管的库(参见maven central中的jms 1.1发生了什么?)
因此可以添加jcenter()存储库

repositories {
    jcenter()
    mavenCentral()
}

但是,对于其他应排除的可传递lib,您将遇到其他问题:从可传递依赖项中排除log4j或jdmk和jmx,如下所示:

dependencies {
    api 'org.apache.commons:commons-math3:3.6.1'
    implementation 'com.google.guava:guava:23.0'
    testImplementation 'junit:junit:4.12'

    compile(group: 'org.apache.kafka', name: 'kafka_2.10', version: '0.8.0'){
        exclude group : "com.sun.jdmk"
        exclude group : "com.sun.jmx"

        // or simply exclude all  log4j:
        //  exclude group : "log4j"
    }
    compile 'org.apache.kafka:kafka-clients:0.10.2.0'
}

有关log4j 1.2.15问题的模式详细信息:http://unitstep.net/blog/2009/05/18/resolving-log4j-1215-dependency-problems-in-maven-using-exclusions/

相关问题