Apache Beam:找不到DataflowRunner

Utk*_*tku 5 java google-cloud-dataflow apache-beam

我正在尝试DirectRunner在Google Cloud Dataflow上运行能够成功运行的管道。当我执行此Maven命令时:

mvn compile exec:java \
    -Dexec.mainClass=com.example.Pipeline \
    -Dexec.args="--project=project-name \
    --stagingLocation=gs://bucket-name/staging/ \
    ... custom arguments ...
    --runner=DataflowRunner"
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

No Runner was specified and the DirectRunner was not found on the classpath.
[ERROR] Specify a runner by either:
[ERROR]     Explicitly specifying a runner by providing the 'runner' property
[ERROR]     Adding the DirectRunner to the classpath
[ERROR]     Calling 'PipelineOptions.setRunner(PipelineRunner)' directly
Run Code Online (Sandbox Code Playgroud)

我有意DirectRunner从我的收藏夹中删除pom.xml并添加了以下内容:

<dependency>
    <groupId>org.apache.beam</groupId>
    <artifactId>beam-runners-google-cloud-dataflow-java</artifactId>
    <version>2.0.0</version>
    <scope>runtime</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)

我继续删除了<scope>标签,然后调用了options.setRunner(DataflowRunner.class),但没有帮助。PipelineOptions从扩展我自己的界面DataflowPipelineOptions也不能解决问题。

看起来它忽略runner了我无法调试的选项。

更新:这是完整的pom.xml,以防万一:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>dataflow</artifactId>
    <version>0.1</version>

    <dependencies>
        <dependency>
            <groupId>org.apache.beam</groupId>
            <artifactId>beam-sdks-java-core</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.beam</groupId>
            <artifactId>beam-runners-google-cloud-dataflow-java</artifactId>
            <version>2.0.0</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.beam</groupId>
            <artifactId>beam-sdks-java-io-jdbc</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.beam</groupId>
            <artifactId>beam-sdks-java-io-google-cloud-platform</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.1.4.jre7</version>
        </dependency>
    </dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)

Utk*_*tku 4

忘记将 PipelineOptions 实例作为参数传递给Pipeline.create()方法是导致我的问题的原因。

PipelineOptionsFactory.register(MyOptions.class);
MyOptions options = PipelineOptionsFactory.fromArgs(args).withValidation().as(MyOptions.class);
Pipeline pipeline = Pipeline.create(options); // Don't forget the options argument.
...
pipeline.run();
Run Code Online (Sandbox Code Playgroud)