加速maven jar包, pom下载速度 - aliyun Maven仓库

叁歲伎倆 2022-07-15 10:20 423阅读 0赞

生活在瓷器国, 用默认的maven仓库地址下载jar包真是下的心都碎了, B/s的速度…

还好国人给力, 有阿里云maven仓库这种东西, 从此走上了快速路

方法:

修改maven的conf目录下的settings.xml文件, 加上mirror节点

  1. <mirror>
  2. <id>alimaven</id>
  3. <name>aliyun maven</name>
  4. <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
  5. <mirrorOf>central</mirrorOf>
  6. </mirror>

腾讯云maven仓库:

  1. <mirror>
  2. <id>nexus-tencentyun</id>
  3. <mirrorOf>*</mirrorOf>
  4. <name>Nexus tencentyun</name>
  5. <url>http://mirrors.cloud.tencent.com/nexus/repository/maven-public/</url>
  6. </mirror>

Enjoy the speed.

后续:

阿里云的maven虽好,但是有时项目中需要用到自己封装的特殊jar包,这个jar包只在公司的私服上,这里提供两种实现方式。

方法一:在项目的pom.xml中配置公司私服地址

  1. <project ...>
  2. <repositories>
  3. <repository>
  4. <id>公司私服名称,如:JBoss repository</id>
  5. <url>私服地址,如:http://repository.jboss.org/nexus/content/groups/public/</url>
  6. </repository>
  7. </repositories>
  8. </project>

方法二:在settings.xml中配置(推荐)

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  5. <mirrors>
  6. <mirror>
  7. <id>alimaven</id>
  8. <name>aliyun maven</name>
  9. <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
  10. <mirrorOf>central</mirrorOf>
  11. </mirror>
  12. </mirrors>
  13. <localRepository>C:\repository</localRepository>
  14. <profiles>
  15. <profile>
  16. <id>company-repo</id>
  17. <repositories>
  18. <repository>
  19. <id>public</id>
  20. <url>公司私服地址,如:http://10.1.2.3:8080/nexus/content/groups/public/</url>
  21. <name>company-repository</name>
  22. </repository>
  23. </repositories>
  24. </profile>
  25. </profiles>
  26. <activeProfiles>
  27. <activeProfile>company-repo</activeProfile>
  28. </activeProfiles>
  29. </settings>

参考:https://segmentfault.com/a/1190000017402970

发表评论

表情:
评论列表 (有 0 条评论,423人围观)

还没有评论,来说两句吧...

相关阅读