首先, maven 3.3及以上版本,須要JDK 1.7版本以上的。因此確保項目 使用的JDK是 jdk1.7版本以上的。不然出現什麼不兼容的也很差。apache
1,瀏覽器
An alternative if jaipster's answer does not work is to go to:
Window > Preferences > Java > Installed JREs網絡
Then to edit the jre so that it points to the jdk and not the jre (the jre home filed in the jre package editor)eclipse
That worked for me.maven
maven 在eclipse 中不能打包的 狀況 解決:No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
首先在 eclipse裏面 Windows -- 將 intstalled JRES 的 路徑指向JDK的安裝路徑 ,而不是 jre的路徑 ,而後 右擊項目 在 Properties 裏面 將
Java cmpile 改成對應系統 的jdk版本 ,Java build path 該爲默認的jre 也就是指向 jdk 路徑的那個ide
通過測試 項目裏面 的 Properties 均可以不用修改,只要修改默認 的 jre 指向 jdk的路徑就能夠了測試
項目使用的JDK版本是 1.7以上的,不是的話,換過了, maven-- Update project--便可。ui
,2,this
當咱們對項目進行打包的時候,常常容易出現問題。debug
首先確保 maven clean 可以沒有問題,通常是沒有問題的啦。
好比, maven install 的問題:
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:
test (default-test) on project project_om: Execution default-test of goal
org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test failed: Plugin org.apache.maven.plugins:maven-surefire-plugin:2.12.4
or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-surefire-plugin:jar:2.12.4
-> org.apache.maven.surefire:surefire-booter:jar:2.12.4: Failed to read artifact
descriptor for org.apache.maven.surefire:surefire-booter:jar:2.12.4: Could not
transfer artifact org.apache.maven.surefire:surefire-booter:pom:2.12.4 from/to
central (https://repo.maven.apache.org/maven2): RSA premaster secret
error: SunTls12RsaPremasterSecret KeyGenerator not available -> [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.
剛開始的時候,我也是 百度一通,通常百度不出來,問題解決辦法也不對口。
咱們認真看看 錯誤日誌便可。這裏說 好比 maven-surefire-plugin:jar:2.12.4
和 surefire-booter:jar:2.12.4 包
這個 jar的問題。
去後臺maven 倉庫看看,果真這個jar包沒有 下載成功。因此打包不經過。那麼咱們去網上 找到 這個 jar的 maven 導入 方式。 將 這個 jar 包 引入方式, 放入 項目 pom.xml ,好比:
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-booter</artifactId>
<version>2.12.4</version>
</dependency>
讓其下載成功。若是發現仍是沒有下載成功,或者是下載太慢,咱們能夠去網上手動下載好 jar包,丟進去 maven 倉庫裏面,而後 maven-- Update project--便可。 接着 繼續 maven install 這時候可能會出現錯誤,錯誤: xxx.jar 的問題,一樣的原裏,把他們都 引入 pom.xml 下載到 maven倉庫裏面 ,一直到把相關的jar包引入便可。
也就是說 maven install 有可能不會幫咱們把一些依賴的 jar包給咱們下載下來,或者它下載了沒有下載成功。致使的jar包不全,引發的問題。最好問題完美解決。
3,
好比若是咱們打包的時候 出現
好比 http://10.10.99.112:8081/nexus/ reduce connection 拒絕鏈接什麼的,
那麼就是網絡問題了。好比 一些公司就有本身的 maven 私庫, 再 setting.xml 或者項目 pom.xml 配置文件 配置了 私庫的地址 ,那麼 出現 打包的時候,下載 鏈接 jar 包, 拒絕鏈接 xxx地址的時候,就是 說明 你的 私庫 地址錯了, 或者是 你的電腦沒有 訪問 改私庫地址的權限。
對於私庫 咱們能夠 在 瀏覽器 裏面 輸入 地址 好比 : http://10.10.99.112:8081/nexus/ 去 查看私庫裏面的 jar包的狀況的.
4,
Failed to execute goal on project crm: Could not resolve dependencies for project
com.skg.crm:crm:war:1.0.0: Failure to find com.skg.crm:wechat-biz:jar:1.0.0 in
http://10.10.99.112:8081/nexus/content/groups/public/ was cached in the local
repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates
are forced -> [Help 1]
[ERROR]
這個意思是 ,在 公司的 maven 私庫 裏面 並無 wechat-biz:jar 包了,刪掉了
可是目前項目的 pom.xml 裏面有引用到的 。
改過來 去掉 依賴 包 或者是 從之前的代碼裏面 install 打包一份 對應項目的 jar 放入你本地的 maven 倉庫 就行了,而後 maven -Update project
5,
若是maven 的項目pom.xml出現 Missing artifact xxx.jar 出現了問題,那麼能夠去到對於的maven 的jar 的倉庫裏面, 將對應的包 的其餘文件給刪除,好比刪除 Update xxx 文件這些之類的,而後 Upadate maven project 便可