Java 错误:未指定任何运行程序,并且在类路径上找不到DirectRunner
我正在运行flink 1.6.1的单节点flink集群上运行一个单词计数示例 并不断得到这个错误 我使用的是beam版本2.8.0 错误 主类 `Java 错误:未指定任何运行程序,并且在类路径上找不到DirectRunner,java,apache-flink,apache-beam,flink-cep,Java,Apache Flink,Apache Beam,Flink Cep,我正在运行flink 1.6.1的单节点flink集群上运行一个单词计数示例 并不断得到这个错误 我使用的是beam版本2.8.0 错误 主类 ` `必须在pipleline中指定流道。有两种方法可以设置它,一种是使用pipeline.setRunner()方法设置要使用的梁流道,另一种是在命令行中指定梁流道,例如: java -jar your_application.jar --runner=FlinkRunner 您的代码应该如下所示: public class PipelineData
`必须在pipleline中指定流道。有两种方法可以设置它,一种是使用
pipeline.setRunner()
方法设置要使用的梁流道,另一种是在命令行中指定梁流道,例如:
java -jar your_application.jar --runner=FlinkRunner
您的代码应该如下所示:
public class PipelineDataHandler {
public static void main(String[] args) {
PipelineOptions options = PipelineOptionsFactory.create();
Pipeline p = Pipeline.create(options);
p.setRunner(FlinkRunner.class)
counter.inc();
p.apply(Create.of(LINES)).setCoder(StringUtf8Coder.of())
.apply(
FlatMapElements.into(TypeDescriptors.strings())
.via((String word) -> Arrays.asList(word.split("[^\\p{L}]+"))))
// We use a Filter transform to avoid empty word
.apply(Filter.by((String word) -> !word.isEmpty()))
.apply(Count.perElement())
.apply(
MapElements.into(TypeDescriptors.strings())
.via(
(KV<String, Long> wordCount) ->
wordCount.getKey() + ": " + wordCount.getValue()))
.apply(TextIO.write().to("wordcounts"));
p.run().waitUntilFinish();}}
公共类PipelineDataHandler{
公共静态void main(字符串[]args){
PipelineOptions=PipelineOptionsFactory.create();
Pipeline p=Pipeline.create(选项);
p、 setRunner(FlinkRunner.class)
counter.inc();
p、 apply(创建(行)).setCoder(StringUtf8Coder.of())
.申请(
FlatMapElements.into(TypeDescriptors.strings())
.via((字符串字)->Arrays.asList(字.split([^\\p{L}]+]))
//我们使用过滤器转换来避免空字
.apply(Filter.by((字符串字)->!word.isEmpty())
.apply(Count.perElement())
.申请(
MapElements.into(TypeDescriptors.strings())
.通过(
(千伏字数)->
wordCount.getKey()+:“+wordCount.getValue()))
.apply(TextIO.write().to(“字数”);
p、 run().waitUntilFinish();}}
必须在pipleline中指定转轮。有两种设置方法,一种是使用pipeline.setRunner()方法设置要使用的梁转轮,另一种是在命令行中指定梁转轮,例如:java-jar your_application.jar--runner=FlinkRunner
repositories {
jcenter()
mavenLocal()
mavenCentral()
}
apply plugin: 'org.owasp.dependencycheck'
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'
mainClassName = 'com.rnd.beam.PipelineDataHandler' //com/rnd/beam/PipelineDataHandler
sourceCompatibility = 1.8
dependencies {
compile('org.apache.beam:beam-sdks-java-core:2.8.0')
compile('org.apache.beam:beam-runners-flink_2.11:2.8.0')
// testCompile('org.apache.beam:beam-runners-direct-java:2.8.0')
testCompile('org.testng:testng:6.14.+')
}
jar {
manifest {
attributes(
'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
'Main-Class': 'com.rnd.beam.PipelineDataHandler'
)
}
}
java -jar your_application.jar --runner=FlinkRunner
public class PipelineDataHandler {
public static void main(String[] args) {
PipelineOptions options = PipelineOptionsFactory.create();
Pipeline p = Pipeline.create(options);
p.setRunner(FlinkRunner.class)
counter.inc();
p.apply(Create.of(LINES)).setCoder(StringUtf8Coder.of())
.apply(
FlatMapElements.into(TypeDescriptors.strings())
.via((String word) -> Arrays.asList(word.split("[^\\p{L}]+"))))
// We use a Filter transform to avoid empty word
.apply(Filter.by((String word) -> !word.isEmpty()))
.apply(Count.perElement())
.apply(
MapElements.into(TypeDescriptors.strings())
.via(
(KV<String, Long> wordCount) ->
wordCount.getKey() + ": " + wordCount.getValue()))
.apply(TextIO.write().to("wordcounts"));
p.run().waitUntilFinish();}}