文章转载自:https://blog.csdn.net/jianzhonghao/article/details/72858465

Eclipse导入maven项目时,Pom.xml文件报错处理方法

导入maven项目,FIle→Import→Existing Maven Projects→找到自己想要导入的文件目录→Finish。项目就导入完成啦。接着就遇上了各种报错!!

一、Pom.xml文件第一次报错

CoreException: Could not get the value for parameter compilerId for plugin execution default-testCompile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven:maven-plugin-api:jar:2.0.9, org.apache.maven:maven-artifact:jar:2.0.9, org.apache.maven:maven-core:jar:2.0.9: Failure to transfer org.apache.maven:maven-plugin-api:jar:2.0.9 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-plugin-api:jar:2.0.9 from/to central (https://repo.maven.apache.org/maven2): connect timed out。

解决方法:

这是因为网络原因,导致文件没有下载完成。

在电脑中搜索xxx.jar.lastUpdated,并将其都删除即可,具体步骤如下:

1)找到 {user}/.m2/repository

2)搜索“.lastupdated”。(如果不记得对应的.m2位置,可以全计算机搜索)Windows将展示所有文件夹的目录。

3)选中对应的lastupdated文件,并删除。

4)重新打开(若先前未关闭,请关闭后重新打开)Eclipse,右键报错的项目,并选择Maven > Update Project。同时记得勾选Force Update of Snapshots/Releases”. 点击OK,这样就解决了依赖关系。

 

 

二、Pom.xml文件再次报错

[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-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1][ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.[ERROR] Re-run Maven using the -X switch to enable full debug logging.[ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles:[ERROR] [Help 1]http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException

解决方法:

右击报错的项目→Properties→Project Facets→Runtimes→勾选Apache Tomcat v7.0

在Project Facets处找不到Runtimes时,需要点击下图Convert to faceted from…



 



 

三、Pox.xml最后报错

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project mrpapp: Compilation failure

[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

解决方法:

在eclipse中找到Window → Preferences → Java → Installed JREs,在jRE home中修改为你安装的jdk的目录位置。



 

好了,3个报错都被处理了,现在我就可以开心的运行项目啦!

GitHub 加速计划 / ma / maven
4.37 K
2.67 K
下载
Maven: Apache Maven是一个开源的项目管理和构建工具,主要用于Java项目。适合需要自动化项目构建和依赖管理的开发者。特点包括约定优于配置、易于使用和社区驱动。
最近提交(Master分支:1 个月前 )
227b13a9 15 天前
c0866ec0 15 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐