Eclipse导入maven项目时,Pom.xml文件报错处理方法 | 您所在的位置:网站首页 › 导入maven项目pom文件报错 › 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个报错都被处理了,现在我就可以开心的运行项目啦! |
CopyRight 2018-2019 实验室设备网 版权所有 |