我写了这个管道,但是当我以jar形式运行它时,当我在build.gradle中指定它并且尝试传递参数--runner = direct或
--runner = Directrunner。以下是我的代码和build.gradle文件。我正在运行gradle任务fatJar创建jar,然后导航到build / libs文件夹以运行jar并看到此错误。这是我正在使用的命令brew install solr
对此问题的任何帮助将不胜感激!
我的文件夹结构如下: --src - 主要 --java --com.pipeline --BeamPipeline.java
build.gradle
brew search solr
管道:
java -jar filepipeline-all-1.0-SNAPSHOT.jar --input="../testdata" --output="./manifest.json" --runner=DirectRunner
答案 0 :(得分:1)
beam-runners-direct-java
被添加为运行时依赖项,因此未添加到胖子容器中。
您可以添加beam-runners-direct-java
作为编译时依赖项来使用它。
plugins {
id 'java'
}
group 'com.dustin'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Gradle Jar File',
'Implementation-Version': version,
'Main-Class': 'com.pipeline.BeamPipeline'
}
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
apply plugin: 'application'
mainClassName = 'src.main.java.com.pipeline.BeamPipeline'
dependencies {
compile group: 'org.apache.beam', name: 'beam-runners-direct-java', version:'2.8.0'
compile group: 'org.apache.beam', name: 'beam-sdks-java-core', version:'2.8.0'
runtime group: 'org.slf4j', name: 'slf4j-jdk14', version:'1.7.25'
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
compile group: 'commons-io', name: 'commons-io', version: '2.6'
compile group: 'commons-codec', name:'commons-codec', version:'1.12'
compileOnly 'org.projectlombok:lombok:1.18.6'
compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
compile group: 'org.json', name: 'json', version: '20180813'
annotationProcessor 'org.projectlombok:lombok:1.18.6'
}
或者,如果您不想将DirectRunner
与fatjar打包,而只想将其用于测试,则可以创建单独的DirectRunner
jar,并在运行管道时将其添加到类part中。
plugins {
id 'java'
}
group 'com.dustin'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Gradle Jar File',
'Implementation-Version': version,
'Main-Class': 'com.pipeline.BeamPipeline'
}
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
task directrunnerjar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Gradle Jar File',
'Implementation-Version': version,
'Main-Class': 'com.pipeline.BeamPipeline'
}
baseName = project.name + '-runtime'
from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
apply plugin: 'application'
mainClassName = 'src.main.java.com.pipeline.BeamPipeline'
dependencies {
runtime group: 'org.apache.beam', name: 'beam-runners-direct-java', version:'2.8.0'
compile group: 'org.apache.beam', name: 'beam-sdks-java-core', version:'2.8.0'
runtime group: 'org.slf4j', name: 'slf4j-jdk14', version:'1.7.25'
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
compile group: 'commons-io', name: 'commons-io', version: '2.6'
compile group: 'commons-codec', name:'commons-codec', version:'1.12'
compileOnly 'org.projectlombok:lombok:1.18.6'
compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
compile group: 'org.json', name: 'json', version: '20180813'
annotationProcessor 'org.projectlombok:lombok:1.18.6'
}
java -cp "libs/myartifact-runtime-1.0-SNAPSHOT.jar:libs/filepipeline-all-1.0-SNAPSHOT" com.pipeline.BeamPipeline --input="../testdata" --output="./manifest.json" --runner=DirectRunner