? ? ? 導(dǎo)入maven項(xiàng)目,F(xiàn)Ile→Import→Existing Maven Projects→找到自己想要導(dǎo)入的文件目錄→Finish。項(xiàng)目就導(dǎo)入完成啦。接著就遇上了各種報(bào)錯(cuò)!!
一、Pom.xml文件第一次報(bào)錯(cuò)
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。
解決方法:
這是因?yàn)榫W(wǎng)絡(luò)原因,導(dǎo)致文件沒有下載完成。
在電腦中搜索xxx.jar.lastUpdated,并將其都刪除即可,具體步驟如下:
1)找到 {user}/.m2/repository
2)搜索“.lastupdated”。(如果不記得對(duì)應(yīng)的.m2位置,可以全計(jì)算機(jī)搜索)Windows將展示所有文件夾的目錄。
3)選中對(duì)應(yīng)的lastupdated文件,并刪除。
4)重新打開(若先前未關(guān)閉,請(qǐng)關(guān)閉后重新打開)Eclipse,右鍵報(bào)錯(cuò)的項(xiàng)目,并選擇Maven > Update Project。同時(shí)記得勾選Force Update of Snapshots/Releases". 點(diǎn)擊OK,這樣就解決了依賴關(guān)系。

二、Pom.xml文件再次報(bào)錯(cuò)
[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
解決方法:
右擊報(bào)錯(cuò)的項(xiàng)目→Properties→Project Facets→Runtimes→勾選Apache Tomcat v7.0
在Project Facets處找不到Runtimes時(shí),需要點(diǎn)擊下圖Convert to faceted from...


三、Pox.xml最后報(bào)錯(cuò)
[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個(gè)報(bào)錯(cuò)都被處理了,現(xiàn)在我就可以開心的運(yùn)行項(xiàng)目啦!