[英]Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin AND more
The project has only one package containing all the .java files. 该项目只有一个包含所有.java文件的软件包。
When I run it using maven, it complains: 当我使用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:
A dozen of errors look like these: 一系列错误如下所示:
[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'
I have checked the eclipse settings, 我已经检查了日食设置
and 和
As you can see, I have assigned the "installed JRE" and it matches the jre used by compiler. 如您所见,我分配了“已安装的JRE”,它与编译器使用的jre相匹配。
And I have used vim to check the coding of TokenJob.java file, it looks ok. 而且我已经使用vim来检查TokenJob.java文件的编码,看起来还可以。
All "errors" are around TokenJob.java file, so I commented the whole class leaving only 所有“错误”都在TokenJob.java文件周围,因此我注释了整个类,仅留下了
public class TokenJob {}
Then odd things happen, some other java files ask me to import
java file that is already located in the same package, which should not. 然后发生了奇怪的事情,其他一些Java文件要求我
import
已经位于同一软件包中的Java文件,而不应该这样做。
I tried to copy TokenJob out and back, the same. 我尝试将TokenJob复制回来,同样。 I tried the above operation several times, and the "import java file in the same package" happens at random references/places.
我多次尝试了上述操作,并且“在同一包中导入Java文件”发生在随机引用/位置。
This is my pom: 这是我的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>
All I want is getting the jar file using maven. 我想要的只是使用maven获取jar文件。 Thanks!
谢谢!
我认为问题在于阴影插件,因此请仔细阅读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.