小编Gid*_*eon的帖子

从 Maven 构建的 jar 运行 Apache Beam/Google Cloud Dataflow 作业

我有一个使用以下命令字符串从 IntelliJ IDEA 运行的 Google Cloud Dataflow 作业:

compile exec:java -Dexec.mainClass=com.mygroup.mainclass "-Dexec.args=--..."
Run Code Online (Sandbox Code Playgroud)

它从这里运行良好,我想将它部署到本地服务器上,以便在构建时自动运行。args 指定管道选项;在任何给定的构建中,我们需要使用此管道启动三个不同的作业,并且必须重新编译三次是浪费。所以我使用 mvn package 以下列方式生成一个 jar 文件:

clean compile assembly:single
Run Code Online (Sandbox Code Playgroud)

问题是,当我通过项目目标目录中的 java -jar my_pipeline-1.0-SNAPSHOT-jar-with-dependencies.jar --args 运行管道时,出现异常:

Exception in thread "main" java.lang.IllegalArgumentException:
Unknown 'runner' specified 'DataflowRunner', supported pipeline runners [DirectRunner]
Run Code Online (Sandbox Code Playgroud)

Beam 邮件列表上的帖子建议通过 -Pdataflow-runner 在执行时设置类路径,但如果我只是调用 jar,我还没有找到使该工作起作用的方法。我已经尝试在编译和打包步骤中指定配置文件,但这并没有帮助。

这是我的 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.mygroup</groupId>
    <artifactId>data_dump</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <slf4j.version>1.7.5</slf4j.version>
        <junit.version>4.8.2</junit.version>
        <hamcrest.version>1.3</hamcrest.version>
        <mockito.version>1.10.19</mockito.version>
        <bigquery.version>v2-rev312-1.22.0</bigquery.version>
        <powermock.version>1.6.6</powermock.version>
        <beam.version>2.0.0</beam.version>
    </properties>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest> …
Run Code Online (Sandbox Code Playgroud)

jar maven maven-assembly-plugin google-cloud-dataflow apache-beam

6
推荐指数
1
解决办法
4678
查看次数