我在运行 flink 程序时遇到一些问题,这是错误:
java.lang.NoSuchMethodError: io.netty.buffer.CompositeByteBuf.addComponents(ZLjava/lang/Iterable;)Lio/netty/buffer/CompositeByteBuf;
at org.elasticsearch.transport.netty4.Netty4Utils.toByteBuf(Netty4Utils.java:78)
at org.elasticsearch.transport.netty4.Netty4Transport.sendMessage(Netty4Transport.java:449)
at org.elasticsearch.transport.netty4.Netty4Transport.sendMessage(Netty4Transport.java:91)
at org.elasticsearch.transport.TcpTransport$ScheduledPing.doRunInLifecycle(TcpTransport.java:261)
at org.elasticsearch.common.util.concurrent.AbstractLifecycleRunnable.doRun(AbstractLifecycleRunnable.java:67)
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:527)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
我查看了SO,发现有人遇到了同样的问题,建议是遮蔽Netty,并将其包含在我的pom中:
这是我添加的内容:
<build>
<plugins>
<!-- disable the exclusion rules -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes combine.self="override">
<exclude>io.netty:netty-all</exclude>
<exclude>io.netty:netty</exclude>
</excludes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
但问题仍然存在。如果有人有想法,请与我分享,谢谢。
可能是版本问题。您添加的另一个库中的库将覆盖另一个库。我的意思是:你在 pom:a 中有 2 个依赖项,而 b.dependency a 有一个不同版本的 b,所以它会覆盖你添加到 pom 中的库 b。