[英]Maven: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile
[英]Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin AND more
該項目只有一個包含所有.java文件的軟件包。
當我使用maven運行它時,它抱怨:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project wx.center: Compilation failure: Compilation failure:
一系列錯誤如下所示:
[ERROR] C:\Users\...\wx\center\TokenJob.java:[57,53] ERROR: needs';'
[ERROR] C:\Users\...\wx\center\TokenJob.java:[88,10] ERROR: there is 'catch', but no 'try'
[ERROR] C:\Users\...\wx\center\TokenJob.java:[88,26] ERROR: needs')'
[ERROR] C:\Users\...\wx\center\TokenJob.java:[90,10] ERROR: there is 'finally', but no 'try'
和
如您所見,我分配了“已安裝的JRE”,它與編譯器使用的jre相匹配。
而且我已經使用vim來檢查TokenJob.java文件的編碼,看起來還可以。
所有“錯誤”都在TokenJob.java文件周圍,因此我注釋了整個類,僅留下了
public class TokenJob {}
然后發生了奇怪的事情,其他一些Java文件要求我import
已經位於同一軟件包中的Java文件,而不應該這樣做。
我嘗試將TokenJob復制回來,同樣。 我多次嘗試了上述操作,並且“在同一包中導入Java文件”發生在隨機引用/位置。
這是我的pom:
<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.xxxx</groupId>
<artifactId>wx.center</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.xxxx.wx.center.MainClass</mainClass>
</transformer>
</transformers>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>executable</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
我想要的只是使用maven獲取jar文件。 謝謝!
我認為問題在於陰影插件,因此請仔細閱讀https://maven.apache.org/plugins/maven-shade-plugin/替代解決方案可能是http://www.mkyong.com/maven/how-to -用jar創建一個jar文件/
嘗試刪除eclipse
Markers
和Problems
選項卡中的所有內容,然后嘗試構建項目。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.