我有一个Google Cloud Dataflow作业,我正在使用以下命令字符串从IntelliJ IDEA运行该作业:
compile exec:java -Dexec.mainClass=com.mygroup.mainclass "-Dexec.args=--..."
它从这里运行良好,我想把它部署到本地服务器上,以便在构建时自动运行。参数指定管道选项;在任何给定的构建中,我们都需要使用这个管道启动三个不同的作业,并且重新编译三次是很浪费的。所以我正在使用mvn包以以下方式生成一个jar文件:
clean compile assembly:single
问题是,当我通过项目目标目录中的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]
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>
<mainClass>com.mygroup.mainclass</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>.</classpathPrefix>
<mainClass>com.mygroup.mainclass</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<aggregate>true</aggregate>
</configuration>
<executions>
<execution>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>direct-runner</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<!-- Makes the DirectRunner available when running a pipeline. -->
<dependencies>
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-runners-direct-java</artifactId>
<version>${beam.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>dataflow-runner</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>com.google.cloud.dataflow</groupId>
<artifactId>google-cloud-dataflow-java-sdk-all</artifactId>
<version>${beam.version}</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>flink-runner</id>
<!-- Makes the FlinkRunner available when running a pipeline. -->
<dependencies>
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-runners-flink_2.10</artifactId>
<version>${beam.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-sdks-java-core</artifactId>
<version>${beam.version}</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
<version>0.18.0-beta</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud.dataflow</groupId>
<artifactId>google-cloud-dataflow-java-sdk-all</artifactId>
<version>${beam.version}</version>
</dependency>
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-runners-direct-java</artifactId>
<version>${beam.version}</version>
</dependency>
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-sdks-java-io-google-cloud-platform</artifactId>
<version>${beam.version}</version>
</dependency>
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-runners-google-cloud-dataflow-java</artifactId>
<version>${beam.version}</version>
<scope>runtime</scope>
</dependency>
<!-- slf4j API frontend binding with JUL backend -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-storage</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>com.esotericsoftware.yamlbeans</groupId>
<artifactId>yamlbeans</artifactId>
<version>1.08</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>3.4</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>apache-maven-repo</id>
<name>Apache Nightlies</name>
<url>https://repository.apache.org/content/repositories/snapshots/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>
好吧,我解决了。我的POM有几处不对劲。
首先,依赖关系的顺序不对。我将Beam-Runners-Google-Cloud-Dataflow-Java依赖项移到列表的顶部,然后我收到的错误就消失了。
我还遇到了另一个例外:
Caused by: java.lang.IllegalStateException: Unable to find registrar for gs.
按照这个问题中的说明,使用package而不是assembly进行构建,我能够启动我的工作。咻!
问题内容: 我对Maven的口头禅还比较陌生,但是我正在尝试使用Maven构建命令行可运行jar。我已经设置了依赖项,但是当我运行并尝试运行jar时,会发生两件事。首先,没有找到可纠正的主类。更正此错误后,在运行时出现错误,指出找不到类。 Maven没有将我的依赖库打包在jar中,因此我无法将jar作为独立应用程序运行。我该如何纠正? 问题答案: 最简单的方法是使用和预定义描述符创建一个程序集。您
我是JavaFX的新手。我用maven创建了JavaFX项目,并添加了所有依赖项。idea中的Project工作得很好,但当我在maven中构建它并尝试在目标文件夹中打开时,jar没有反应,它会给出以下错误。 (未知源)在com.sun.javafx.application.launcherImpl$$lambda$51/881058039。运行(Unkn自己的源)在com.sun.javafx.
我刚开始使用springboot和springboot 2版本。 但是,当我使用eclipse构建应用程序时,它直接调用myService.getMyMethod()而不构建JAR。 我想首先构建jar文件,然后从命令提示符运行java-jar my-app-0.0.1-snapshot.jar,这将调用MyService.getMyMethod() 我在pom.xml中已经有了spring-bo
目前,我们正在库伯内特斯上使用自己安装的气流版本,但想法是在云作曲家上迁移。我们使用Airflow运行数据流作业,使用DataFlowJavaoperator的自定义版本(使用插件),因为我们需要执行java应用程序,而java应用程序不是在jar中自包含的。因此,我们基本上运行一个bash脚本,该脚本使用以下命令: 所有jar依赖项都存储在所有辅助角色之间的共享磁盘中,但是在Composer中缺
问题内容: 我试图使用maven为名为“ logmanager”的小型家庭项目生成可执行jar,如下所示: 如何使用Maven创建具有依赖项的可执行JAR? 我将此处显示的代码段添加到pom.xml中,并运行了mvn assembly:assembly。它在logmanager / target中生成两个jar文件:logmanager-0.1.0.jar和logmanager-0.1.0-jar
问题内容: 使用Maven 3.1 Eclipse Helios Aspekt: 尝试使用maven-jar / dependency-plugins创建可运行的jar文件。 问题: 创建jar文件和依赖项后,当我尝试使用命令启动jar文件时出现NoCLassDefFoundErrors 但是类/文件可以在./dependency-jars文件夹中找到???我还尝试了以下命令: 这也不起作用。 题