解決 IDEA Maven 插件加載錯誤:Cannot resolve plugin org.apache.maven.plugins:maven-site-plugin:3.8.2


## 起因

配置maven阿里雲時,報錯:Cannot resolve plugin org.apache.maven.plugins:maven-site-plugin:3.8.2

 

## 解決方案:

### 1、上網查了下,多數答案都是本地maven的配置文件和倉庫地址不一致,在file->setting里設置正確即可

![在这里插入图片描述](https://img-blog.csdnimg.cn/20200101214233242.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl8zOTc3ODQxNw==,size_16,color_FFFFFF,t_70)

### 2、更換鏡像

有說聯通網段不能訪問maven的下載地址,配置以下幾種,問題得到解決的。

```xml
<mirrors>
<!-- maven官方鏡像 -->
<mirror>
<id>mirrorId</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name </name>
<url>http://repo1.maven.org/maven2/</url>
</mirror>

<!-- 又一個鏡像 -->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://central.maven.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>

<!-- 阿里雲鏡像 -->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
<mirrorOf>central</mirrorOf>
</mirror>

<!-- junit鏡像地址 -->
<mirror>
<id>junit</id>
<name>junit Address/</name>
<url>http://jcenter.bintray.com/</url>
<mirrorOf>central</mirrorOf>
</mirror>

</mirrors>

```

### 3、最終解決方案

![image-20210927194338314](C:\Users\simon\AppData\Roaming\Typora\typora-user-images\image-20210927194338314.png)

因為我用的是3.8.2版本,從 mvnrepository 查詢了3.8.2 的版本,

> [https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-site-plugin](https://link.ld246.com/forward?goto=https%3A%2F%2Fmvnrepository.com%2Fartifact%2Forg.apache.maven.plugins%2Fmaven-site-plugin)

於是把

```
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-site-plugin -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.8.2</version>
</dependency>
```

加入 pom.xml

這樣就把 jar 文件拉下來,解決。

 

### 總結

1、同樣的鏡像在單位電腦,電信網絡下就好用,換到家里的聯通網絡就不好用,原因不明

```xml
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*,!jeecg,!jeecg-snapshots</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

<mirrors>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/public </url>
</mirror>
</mirrors>

```

2、懷疑聯通網絡下,在不同的網絡波動時,會不定時下載,因為同樣的鏡像,偶爾會下載某幾個包。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM