異常發現
我們創建的項目爲maven項目,我們需要執行命令:maven clean,出現的:“Plugin org.apache.maven.plugins:maven-clean-plugin:3.0.0 or one of its dependencies could not be resolved”異常
異常展示
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:3.0.0 or one of its dependencies could not be resolved: Cannot access nexus-aliyun (http://maven.aliyun.com/nexus/content/groups/public/) in offline mode and the artifact org.apache.maven.plugins:maven-clean-plugin:jar:3.0.0 has not been downloaded from it before. -> [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/PluginResolutionException
核心在第一行意思大意如下圖
問題原因
maven缺少相關的插件依賴,需要聯網下載相關的插件。
解決方法
1、配置的阿里雲私服配置異常(上述提示可以看出,配置地址正確)。
如果阿里雲未配置,可以在maven的setting.xml中配置如下
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
</mirrors>
2、離線無法下載。
這也是本文所遇到的問題是導致無法下載。一般會有兩個原因,首先要確保自己本地是聯網(如果本地都是離線那沒法解決),其次就是我們在maven的setting.xml中將工作環境設置爲了離線模式。
解決:找到本地的maven的setting.xml文件,打開。找到“ <offline>true</offline>”修改爲: “<offline>false</offline>”即可。
<!-- 如果Maven要試圖與用戶交互來得到輸入就設置爲true,否則就設置爲false,默認爲true。 -->
<interactiveMode>true</interactiveMode>
<!-- 如果構建系統要在離線模式下工作,設置爲true,默認爲false。 如果構建服務器因爲網絡故障或者安全問題不能與遠程倉庫相連,那麼這個設置是非常有用的。 -->
<offline>false</offline>