flink启动报错:java.lang.NoClassDefFoundError: scala/collection/immutable/StringOps 解决方法

Posted mask哥

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了flink启动报错:java.lang.NoClassDefFoundError: scala/collection/immutable/StringOps 解决方法相关的知识,希望对你有一定的参考价值。

Exception in thread "main" java.lang.NoClassDefFoundError: scala/collection/immutable/StringOps
    at org.apache.flink.runtime.akka.AkkaUtils$.testDispatcherConfig(AkkaUtils.scala:374)
    at org.apache.flink.runtime.akka.AkkaUtils.testDispatcherConfig(AkkaUtils.scala)
    at org.apache.flink.runtime.minicluster.MiniCluster.createLocalRpcService(MiniCluster.java:951)
    at org.apache.flink.runtime.minicluster.MiniCluster.start(MiniCluster.java:288)
    at org.apache.flink.client.program.PerJobMiniClusterFactory.submitJob(PerJobMiniClusterFactory.java:75)
    at org.apache.flink.client.deployment.executors.LocalExecutor.execute(LocalExecutor.java:85)
    at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.executeAsync(StreamExecutionEnvironment.java:1957)
    at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:1848)
    at org.apache.flink.streaming.api.environment.LocalStreamEnvironment.execute(LocalStreamEnvironment.java:69)
    at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:1834)
    at cn.flink.JavaDataStreamApp.main(JavaDataStreamApp.java:13)
Caused by: java.lang.ClassNotFoundException: scala.collection.immutable.StringOps
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    ... 11 more

解决方法:

默认pom.xml中,scala版本为2.11

<dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-streaming-java_${scala.binary.version}</artifactId>
    <version>${flink.version}</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-clients_${scala.binary.version}</artifactId>
    <version>${flink.version}</version>
    <scope>compile</scope>
</dependency>

查看当前工程中安装的scala版本,是否匹配。如果不存成,就安装匹配的scala 版本

 

 

以上是关于flink启动报错:java.lang.NoClassDefFoundError: scala/collection/immutable/StringOps 解决方法的主要内容,如果未能解决你的问题,请参考以下文章

FlinkFlink 报错 flink 1.12.5 启动作业报 partition not found

flink启动报错:java.lang.NoClassDefFoundError: scala/collection/immutable/StringOps 解决方法

flink启动报错:A JNI error has occurred, please check your installation and try again 解决方法

Flink SQL Client 启动失败 Java版本问题

日常Exception第二十五回:Flink启动job时报错,AbstractChannel$AnnotatedConnectException: Connection refused.....

日常Exception第二十五回:Flink启动job时报错,AbstractChannel$AnnotatedConnectException: Connection refused.....