首页 > 编程知识 正文

idea maven阿里云镜像,maven配置阿里云镜像有什么用

时间:2023-05-05 10:37:34 阅读:192426 作者:3457

好多同学在maven中配置了阿里云镜像后,下载jar包还是很慢,而且有些jar包也不是从阿里云镜像中下载的,如果遇到类似问题,可以往下看我的解决方法。

之所以出现这种问题,是因为一开始我只配置了阿里云中央仓库central,配置的阿里云中央仓库地址中没有spring的相关jar包,maven就会从官方镜像中下载,所以会很慢。

解决方法(配置多个仓库)
1.首先打开maven.aliyun.com,找到你所能用到的相关地址

除了central外,我这里还用到了spring的相关jar包,所以需要添加三个仓库。

2.在 maven 的 setting.xml 的 profiles 节点下配置多个 profile,配置之后要激活

<profile> <id>central</id> <repositories> <repository> <id>central</id> <url>https://maven.aliyun.com/repository/central</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> </profile> <profile> <id>spring</id> <repositories> <repository> <id>spring</id> <url>https://maven.aliyun.com/repository/spring</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> </profile> <profile> <id>spring-plugin</id> <repositories> <repository> <id>spring-plugin</id> <url>https://maven.aliyun.com/repository/spring-plugin</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> </profile>

通过配置 activeProfiles 子节点激活

<activeProfiles> <activeProfile>central</activeProfile> <activeProfile>spring</activeProfile> <activeProfile>spring-plugin</activeProfile> </activeProfiles>

3.记得更新一下。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。