我的项目依赖于 finagle 7.1.0 和相关库,Scala 版本为 2.11.11
当我将 scala 版本升级到 2.12.6 并将 finagle 版本升级为 17.12.0 时,我遇到了错误。
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.twitter.finagle.Init$
at com.twitter.finagle.client.StackClient$.endpointStack(StackClient.scala:54)
at com.twitter.finagle.client.StackClient$.newStack(StackClient.scala:220)
at com.twitter.finagle.builder.ClientConfig$NilClient$.apply$default$1(ClientBuilder.scala:74)
at com.twitter.finagle.builder.ClientConfig$.nilClient(ClientBuilder.scala:91)
at com.twitter.finagle.builder.ClientBuilder.<init>(ClientBuilder.scala:248)
at com.twitter.finagle.builder.ClientBuilder$.apply(ClientBuilder.scala:46)
at com.twitter.finagle.builder.ClientBuilder$.get(ClientBuilder.scala:52)
at com.twitter.finagle.builder.ClientBuilder.get(ClientBuilder.scala)
下面是 finagle 相关 jar 的依赖关系图 -
[INFO] +- com.twitter:finagle-core_2.12:jar:17.12.0:compile
[INFO] | +- com.twitter:finagle-toggle_2.12:jar:17.12.0:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.8:compile
[INFO] | | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.8:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.8.8:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-paranamer:jar:2.8.8:compile
[INFO] | +- com.twitter:finagle-init_2.12:jar:17.12.0:compile
[INFO] | +- com.twitter:util-app_2.12:jar:17.12.0:compile
[INFO] | +- com.twitter:util-cache_2.12:jar:17.12.0:compile
[INFO] | +- com.twitter:util-codec_2.12:jar:17.12.0:compile
[INFO] | +- com.twitter:util-core_2.12:jar:17.12.0:compile
[INFO] | | +- com.twitter:util-function_2.12:jar:17.12.0:compile
[INFO] | | +- org.scala-lang:scala-reflect:jar:2.12.6:compile
[INFO] | | \- org.scala-lang.modules:scala-parser-combinators_2.12:jar:1.0.4:compile
[INFO] | +- com.twitter:util-hashing_2.12:jar:17.12.0:compile
[INFO] | +- com.twitter:util-jvm_2.12:jar:17.12.0:compile
[INFO] | +- com.twitter:util-lint_2.12:jar:17.12.0:compile
[INFO] | +- com.twitter:util-logging_2.12:jar:17.12.0:compile
[INFO] | +- com.twitter:util-registry_2.12:jar:17.12.0:compile
[INFO] | +- com.twitter:util-security_2.12:jar:17.12.0:compile
[INFO] | +- com.twitter:util-stats_2.12:jar:17.12.0:compile
[INFO] | +- com.twitter:util-tunable_2.12:jar:17.12.0:compile
[INFO] | +- com.github.ben-manes.caffeine:caffeine:jar:2.3.4:compile
[INFO] | \- com.google.code.findbugs:jsr305:jar:2.0.1:compile
[INFO] +- org.scala-lang.modules:scala-java8-compat_2.12:jar:0.9.0:compile
[INFO] +- com.twitter:finagle-http_2.12:jar:17.12.0:compile
[INFO] | +- com.twitter:finagle-base-http_2.12:jar:17.12.0:compile
[INFO] | | \- com.twitter:finagle-netty3_2.12:jar:17.12.0:compile
[INFO] | +- com.twitter:finagle-netty3-http_2.12:jar:17.12.0:compile
[INFO] | +- com.twitter:finagle-netty4-http_2.12:jar:17.12.0:compile
[INFO] | | +- com.twitter:finagle-netty4_2.12:jar:17.12.0:compile
[INFO] | | \- io.netty:netty-codec-http:jar:4.1.16.Final:compile
[INFO] | | \- io.netty:netty-codec:jar:4.1.16.Final:compile
[INFO] | +- com.twitter:finagle-http2_2.12:jar:17.12.0:compile
[INFO] | | +- io.netty:netty-codec-http2:jar:4.1.16.Final:compile
[INFO] | | +- io.netty:netty-handler:jar:4.1.16.Final:compile
[INFO] | | | \- io.netty:netty-buffer:jar:4.1.16.Final:compile
[INFO] | | +- io.netty:netty-transport:jar:4.1.16.Final:compile
[INFO] | | | \- io.netty:netty-resolver:jar:4.1.16.Final:compile
[INFO] | | +- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.16.Final:compile
[INFO] | | | \- io.netty:netty-common:jar:4.1.16.Final:compile
[INFO] | | +- io.netty:netty-transport-native-unix-common:jar:4.1.16.Final:compile
[INFO] | | \- io.netty:netty-handler-proxy:jar:4.1.16.Final:compile
[INFO] | | \- io.netty:netty-codec-socks:jar:4.1.16.Final:compile
[INFO] | \- com.twitter:util-collection_2.12:jar:17.12.0:compile
我在这里升级 finagle 版本时确实看到了类似的问题,但在我的情况下,util 依赖项是有效的。
任何想法如何解决这个问题?