Geo*_*ler 6 gradle transitive-dependency dependency-resolution
我与传递依赖有冲突。推翻、排除或强迫都无济于事。我还能做什么才能将正确版本的库放入 jar 中?完整的代码是。找到了https://github.com/geoHeil/gradle-dependency-resolution,但其主要部分如下所述。
执行
./gradlew shadowJar
Run Code Online (Sandbox Code Playgroud)
禁用 geomesa 依赖项(引入过时版本的 typesafe/lightbend 配置库):
dependencies {
compile "com.github.kxbmap:configs_2.11:0.4.4"
//compile "org.locationtech.geomesa:geomesa-hbase-spark-runtime_2.11:2.0.1"
}
Run Code Online (Sandbox Code Playgroud)
并执行 jar
java -jar build/libs/gradleThing-all.jar
Run Code Online (Sandbox Code Playgroud)
输出
hello
my config is: Success(Job1Configuration(frequencyCounting))
Run Code Online (Sandbox Code Playgroud)
启用依赖项时:
./gradlew shadowJar
java -jar build/libs/gradleThing-all.jar
Run Code Online (Sandbox Code Playgroud)
它失败了
hello
Exception in thread "main" java.lang.Exception: Failed to start. There is a problem with the configuration: Vector([extract] com.typesafe.config.Config.hasPathOrNull(Ljava/lang/String;)Z)
Run Code Online (Sandbox Code Playgroud)
这与配置库的过时版本有关,如何解决类型安全配置上的NoSuchMethodError?。还通过以下方式确认:
gradle dependencyInsight --dependency om.typesafe:config
> Task :dependencyInsight
com.typesafe:config:1.3.1 (conflict resolution)
variant "runtime" [
Requested attributes not found in the selected variant:
org.gradle.usage = java-api
]
\--- com.github.kxbmap:configs_2.11:0.4.4
\--- compileClasspath
com.typesafe:config:1.2.1 -> 1.3.1
variant "runtime" [
Requested attributes not found in the selected variant:
org.gradle.usage = java-api
]
+--- org.locationtech.geomesa:geomesa-convert-avro_2.11:2.0.1
| \--- org.locationtech.geomesa:geomesa-convert-all_2.11:2.0.1
| +--- org.locationtech.geomesa:geomesa-tools_2.11:2.0.1
| | \--- org.locationtech.geomesa:geomesa-hbase-spark-runtime_2.11:2.0.1
| | \--- compileClasspath
...
Run Code Online (Sandbox Code Playgroud)
如何修复对我想要的 1.3.3 版本的传递依赖?
尝试设置:
compile("org.locationtech.geomesa:geomesa-hbase-spark-runtime_2.11:2.0.1") {
exclude group: 'com.typesafe', module: 'config'
}
Run Code Online (Sandbox Code Playgroud)
并重新运行 jar 再次失败并出现同样的问题。
implementation("com.typesafe:config")
constraints {
implementation("com.typesafe:config:1.3.3") {
because 'previous versions miss a method /sf/ask/2842757151/'
}
}
Run Code Online (Sandbox Code Playgroud)
implementation('com.typesafe:config:1.3.3') {
force = true
}
Run Code Online (Sandbox Code Playgroud)
或类似:
configurations.all {
resolutionStrategy {
force 'com.typesafe:config:1.3.3'
}
}
Run Code Online (Sandbox Code Playgroud)
没有给出正确的版本。
所有变体均因相同错误而失败
怎么了?必须有一种方法来强制使用所需的版本。
您遇到的问题与您所描述的完全相反。
您在项目中尝试的不同操作都会确保 的版本com.typesafe:config
是1.3.x
.
但是,在添加时,org.locationtech.geomesa:geomesa-hbase-spark-runtime_2.11:2.0.1
您会引入一些已经具有来自com.typesafe:config
但来自该1.2
行的类的依赖项。当您创建 fat jar 时,该版本会覆盖该1.3
行中的类。
这可以通过解压你的 fat jar 并运行来看到:
$ javap com/typesafe/config/Config.class | grep hasPath
public abstract boolean hasPath(java.lang.String);
Run Code Online (Sandbox Code Playgroud)
表明确实hasPathOrNull
缺少该方法。
https://issues.apache.org/jira/browse/SPARK-9441中暗示了该阴影问题。
鉴于此,简单的路径(如果可能的话)是降级"com.github.kxbmap:configs_2.11
到依赖于com.typesafe:config:1.2.x
另一个解决方案是准确找出哪个 fat jar 包含这些内容,看看是否可以将其从您自己的 fat jar 中排除。
归档时间: |
|
查看次数: |
10215 次 |
最近记录: |