解决 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://www.icode9.com/i/ll/?i=20200101214233242.png?,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、怀疑联通网络下,在不同的网络波动时,会不定时下载,因为同样的镜像,偶尔会下载某几个包。

 

上一篇:linux aliyun 本地连接 mysql8.0配置的坑!!!


下一篇:为MFC中的ListBox添加水平滚动条