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个报错都被处理了,现在我就可以开心的运行项目啦!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,973评论 19 139
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 46,969评论 6 342
  • 所有项目的构建都是有生命周期的,这个生命周期包括:项目清理、初始化、编译、测试、打包、集成测试、验证、部署、站点生...
    zlcook阅读 2,833评论 0 21
  • 当前,JVM生态圈主要的三大构建工具: Apache Ant(带着Ivy) Maven Gradle 对于刚开始接...
    清枫_小天阅读 5,834评论 1 13
  • 一阵优美的音乐从一扇白色大门里传出,那扇白色门上有着七彩的音符,最顶端上用彩色的颜色写着“都灵”闪烁着光芒。 ...
    南笙北笺阅读 413评论 0 0