Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin
来源:互联网 发布:淘宝网司法拍卖房产 编辑:程序博客网 时间:2024/06/05 17:58
在使用Maven以及Eclipse的Maven插件时,我和同事遇到了一下几个问题,本着知其然知其所以然的学习精神,总结如下:
- Unrecognised tag
问题
由于我使用本地代理仓库,所以settings.xml设置如下:
但在Maven编译时报了如下异常:- <profiles>
- <profile>
- <id>nexus</id>
- <repositories>
- <repository>
- <id>nexus</id>
- <name>Nexus</name>
- <url>http://localhost:8081/nexus/content/groups/public</url>
- <releases><enabled>true</enabled></releases>
- <snapshots><enabled>true</enabled></snapshots>
- </repository>
- </repositories>
- <pluginRepositories>
- <pluginRepository>
- <id>nexus</id>
- <name>Nexus</name>
- <url>http://localhost:8081/nexus/content/groups/public</url>
- <releases><enabled>true</enabled></releases>
- <snapshots><enabled>true</enabled></snapshots>
- </pluginRepository>
- </pluginRepositories>
- </profile>
- <!--激活配置-->
- <activeProfiles>
- <activeProfile>nexus</activeProfile>
- </activeProfiles>
- </profiles>
解决[WARNING] Some problems were encountered while building the effective settings
[WARNING] Unrecognised tag: 'activeProfiles' (position: START_TAG seen ...\n\t... @269:18) @ C:\Documents and Settings\Administrator.ZQFGROUP.000\.m2\settings.xml, line 269, column 18
[WARNING]
这是因为错把activeProfiles配置到了profiles节点里了,应该把activeProfiles移到profiles之外,更多settings.xml配置信息请参考这里。 - No goals
问题
Eclipse安装了Maven插件后,在项目的pom.xml上右键能看到如下:
而我自作聪明地认为:Maven build 与 mvn compile 是等价的,于是我再点击"Maven build..."之后,“Goals”是空的,如:
于是就报了这样的错误:
解决[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format:or:[:]:. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, post-clean. -> [Help 1]
解决方法至少有两种:- 再点击"Maven build..."之后,输入你要执行的“Goals”,如compile,clean,test等等;
- 在pom.xml中配置默认的Goal,如:
作为project的子节点。- <build>
- <defaultGoal>clean</defaultGoal>
- </build>
- not a JRE
问题
在使用pom.xml配置默认Goal的时,如果默认的Goal为clean就没问题,但如果是如:
就会报错误:- <build>
- <defaultGoal>clean compile</defaultGoal>
- </build>
经过几番尝试,才发现并不是多个Goal的问题,而是compile Goal的问题。但使用命令的"mvn compile"又是OK的。[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project Demo: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre7\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
几经折腾才发现错误里说的很清楚:Please ensure you are using JDK 1.4 or above and not a JRE",它需要的是JDK而不是JRE。我给的项目中使用的是公共JRE:
解决
修改Eclipse的配置,使用JDK:Eclipse->Window->Preferences->Java->Installed JREs
Finish后,项目如:
- maven 构建编译失败:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:
- intellidea maven compile Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:
- 解决Maven test时报错:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin
- maven 构建编译失败:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile
- [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile)
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3. 1
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:解决办法
- 错误Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile)
- [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-c
- [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:31:compile (default-co
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default- comp
- 分布式 Key-Value 存储系统:Cassandra 入门
- UVA 10674 || Tangents(求两圆的共切线
- 寻找论坛资源
- P53 第45题 互不相同无重复3位数
- eclipse安装SVN的方法
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin
- zoj Islands
- Latent Dirichlet Allocation (LDA)
- P53 第46题 完全平方数
- Spring整合CXF,发布RSETful 风格WebService
- 数组的序列化
- Java异常处理笔记
- PacMan开发-Win32的"HelloWorld"&MyRegisterClass()函数
- Python多线程