① maven項目導入後編譯報錯
cc.chengpai.jtd:jtd-service-api:jar:1.0-SNAPSHOT這個包無法載入。
先到本地庫中看下這個包下下來了沒有,下載失敗的話就刪掉重新下。
還是不行的話看下是什麼問題導致的,是網路問題還是庫中沒有這個包,或者是配置問題導致的無法下載,根據問題進行相應解決。
② maven編譯項目報錯了
看看maven的本地倉庫相應的編譯插件有沒有問題。
我的本地倉庫中的依賴包都是用的阿里雲的鏡像倉庫下載的。
③ Eclipse中運行maven伺服器啟動成功但是訪問頁面報404
tomcat中404異常是沒有找到請求的資源。
錯誤原因如下:
1、路徑錯誤
2、web.xml文件映射路徑寫錯
3、伺服器設置
4、servlet的jar包未導進去或者沒有隨項目發布
如果是路徑錯誤,仔細檢查即可解決問題。
伺服器沒設置好也會報這個錯誤,這一般是新手剛開始學時遇到的問題,就是要把eclipse中的tomcat的server location設置為use tomcat installation,在eclipse界面雙擊tomcat server見如圖設置:
④ maven編譯錯誤 d lifecycle pha se or a goal
一、問題描述
Windows下,需要將jar包手動導入Maven本地倉庫,使用Power Shell運行命令:
mvn install:install-file -Dfile="E:\Tools\ipdatabase\target\ipdatabase-1.0-SNAPSHOT.jar" -DgroupId=com.ggstar -DartifactId=ipdatabase -Dversion=1.0 -Dpackaging=jar
報錯:
[ERROR] Unknown lifecycle phase ".ggstar". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. 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/
二、問題原因
Power Shell的命令和cmd的命令有不一樣,這個命令在cmd是可以實行的。
三、解決方法
1.在cmd命令行中執行
在含pom.xml文件的根路徑下打開cmd命令行,然後輸入命令
mvn install:install-file -Dfile="E:\Tools\ipdatabase\target\ipdatabase-1.0-SNAPSHOT.jar" -DgroupId=com.ggstar -DartifactId=ipdatabase -Dversion=1.0 -Dpackaging=jar
然後打包成功:
[INFO] Building ipdatabase 1.0-SNAPSHOT[INFO] ------------------------------------------------------------------------[INFO][INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ ipdatabase ---[INFO] Installing E:\Tools\ipdatabase\target\ipdatabase-1.0-SNAPSHOT.jar to E:\Tools\apache-maven-3.3.9\Repository\com\ggstar\ipdatabase\1.0\ipdatabase-1.0.jar[INFO] Installing C:\Users\ADMINI~1\AppData\Local\Temp\mvninstall4727202787532518137.pom to E:\Tools\apache-maven-3.3.9\Repository\com\ggstar\ipdatabase\1.0\ipdatabase-1.0.pom[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 1.703 s[INFO] Finished at: 2018-10-05T20:40:36+08:00[INFO] Final Memory: 8M/123M[INFO] ------------------------------------------------------------------------
2.在Power Shell下
參數需要添加單引號'',如下命令即可
mvn install:install-file -Dfile="E:\Tools\ipdatabase\target\ipdatabase-1.0-SNAPSHOT.jar" '-DgroupId=com.ggstar' '-DartifactId=ipdatabase' '-Dversion=1.0' '-Dpackaging=jar'
還有不懂的可以關注私聊我,本人10年java開發經驗,相信可以幫助你成為一個優秀的java程序員
⑤ 關於maven編譯項目提示的錯誤信息。
你點Installed JREs,然後Add一個JDK目錄,要是JDK的才可以。完成後要勾選它作為默認的運行環境。