? ? ? 導(dǎo)入maven項目入撒,F(xiàn)Ile→Import→Existing Maven Projects→找到自己想要導(dǎo)入的文件目錄→Finish隆豹。項目就導(dǎo)入完成啦。接著就遇上了各種報錯C┐璃赡!
一判哥、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。
解決方法:
這是因為網(wǎng)絡(luò)原因碉考,導(dǎo)致文件沒有下載完成塌计。
在電腦中搜索xxx.jar.lastUpdated,并將其都刪除即可侯谁,具體步驟如下:
1)找到 {user}/.m2/repository
2)搜索“.lastupdated”锌仅。(如果不記得對應(yīng)的.m2位置,可以全計算機搜索)Windows將展示所有文件夾的目錄墙贱。
3)選中對應(yīng)的lastupdated文件技扼,并刪除。
4)重新打開(若先前未關(guān)閉嫩痰,請關(guān)閉后重新打開)Eclipse,右鍵報錯的項目,并選擇Maven > Update Project窍箍。同時記得勾選Force Update of Snapshots/Releases". 點擊OK串纺,這樣就解決了依賴關(guān)系。
二纺棺、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個報錯都被處理了梭依,現(xiàn)在我就可以開心的運行項目啦典尾!