![](/img/trans.png)
[英]Whitelabel error when running with jar file, but works fine with war file and when run with command mvn spring-boot:run
[英]Google Dataflow job working fine when running on eclipse but gives an error when i compile it using mvn and run the file using java -cp command
我正在從使用Apache Beam的Dataflow sdk 1.x遷移到2.x.當我使用Run as java application在eclipse上運行它時,代碼可以正常運行。但是當我使用mvn clean compile assembly:single對其進行編譯時 ,然后運行使用命令java -cp的類文件,我得到了這些日志,然后是異常
INFO: PipelineOptions.filesToStage was not specified. Defaulting to files
from the classpath: will stage 1 files. Enable logging at DEBUG level to see
which files will be staged.
Apr 25, 2018 11:17:01 AM com.example.LogParser parse
INFO: Currently processing file: File1.gz
Exception in thread "main" java.lang.NoSuchMethodError:
com.google.common.base.Preconditions.checkArgument(ZLjava/lang/
String;Ljava/lang/Object;Ljava/lang/Object;)V at
org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO$Write.expand(BigQueryIO.java:1512)
at org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO$Write.expand(BigQueryIO.java:1041)
at org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:537)
at org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:472)
at org.apache.beam.sdk.values.PCollection.apply(PCollection.java:286)
at com.example.LogParser.parse(LogParser.java:541)
at
com.example.LogParser.main(LogParser.java:167)
我嘗試更新番石榴版本,但沒有幫助。
我還注意到,當我使用eclipse運行類文件時,得到的日志與使用jar文件運行它時的日志不同
INFO: PipelineOptions.filesToStage was not specified. Defaulting to files
from the classpath: will stage 147 files. Enable logging at DEBUG level to
see which files will be staged.
我能夠通過添加這些maven依賴項而不是maven-assembly-plugin,然后使用mvn包而不是mvn Assembly來解決錯誤
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<parallel>all</parallel>
<threadCount>4</threadCount>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${maven-surefire-plugin.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>${project.artifactId}-bundled-${project.version}</finalName>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/LICENSE</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.