构建 Apache Beam Cassandra JAR 时无需重新打包依赖项 [英] No repackaged dependencies when building Apache Beam Cassandra JAR
问题描述
尝试编译和使用 Apache Beam Cassandra JAR 的快照.似乎构建没有在 JAR 中打包 Guava 依赖项.当 JAR 被其他代码使用时,这会导致编译失败 - 请参阅以下异常:
Trying to compile and use the snapshot for Apache Beam Cassandra JAR. Seems like the build does not pack the Guava dependencies within the JAR. This causes compilation to fail when the JAR is used by other code - see following Exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/beam/vendor/guava/v20_0/com/google/common/base/Preconditions
at org.apache.beam.sdk.io.cassandra.CassandraIO$Read.withHosts(CassandraIO.java:180)
at org.apache.beam.examples.JoinFromCassandraToCassandra.main(JoinFromCassandraToCassandra.java:26)
Caused by: java.lang.ClassNotFoundException: org.apache.beam.vendor.guava.v20_0.com.google.common.base.Preconditions
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
无论如何我都找不到使 gradle 构建包成为 JAR 中所需依赖项的方法.
I couldn't find anyway to make the gradle build package the required dependencies within the JAR.
使用命令构建:
gradle -p ./sdks/java/io/cassandra shadowJar
有人知道这是怎么做到的吗?
Anyone knows how this can be done?
更新:显然,几个月前 Beam 使用 Guava 的方式发生了变化.github.com/apache/beam/pull/7494 - 所以当我在本地构建最新版本时,它找不到 org.apache.beam.sdk 导入的 org.apache.beam.vendor.guava.v20_0.com.google.common.options.PipelineOptionsFactory
UPDATE: So apparently a few months ago the way Beam uses Guava has changed. github.com/apache/beam/pull/7494 - So when I build the latest locally it can't find org.apache.beam.vendor.guava.v20_0.com.google.common imported by org.apache.beam.sdk.options.PipelineOptionsFactory
推荐答案
所以看来您需要添加以下依赖项才能使其在最新版本下工作.希望它可以帮助某人.
So it appears you need to add the following dependencies to make it works at the latest version. Hope it helps someone.
<代码>编译组:'org.apache.beam',名称:'beam-vendor-guava-20_0',版本:'0.1'编译组:'org.apache.beam',名称:'beam-vendor-grpc-1_13_1',版本:'0.2'
这篇关于构建 Apache Beam Cassandra JAR 时无需重新打包依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!