flink运行报Exception in thread “main“ java.lang.IllegalStateException
问题描述
运行flink程序时报异常,异常信息如下:
Exception in thread "main" java.lang.IllegalStateException: No ExecutorFactory found to execute the application.
at org.apache.flink.core.execution.DefaultExecutorServiceLoader.getExecutorFactory(DefaultExecutorServiceLoader.java:88)
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.executeAsync(StreamExecutionEnvironment.java:1947)
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 com.example.hadoopspark.flink.psninfo.PsnInfoFlink.saveDataToHdfs(PsnInfoFlink.java:59)
at com.example.hadoopspark.PsnInfoApp.main(PsnInfoApp.java:12)
原因分析:
直接看错误不知道是什么原因,真正的原因是没有导入flink客户端依赖。
解决方案:
在pom.xml
文件中导入flink客户端依赖
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java_2.11</artifactId>
<version>1.13.2</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients_2.11</artifactId>
<version>1.13.2</version>
</dependency>