maven 同时配置私服和阿里云镜像

maven 同时配置私服和阿里云镜像

本文章向大家介绍maven 同时配置私服和阿里云镜像,主要包括maven 同时配置私服和阿里云镜像使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

企业会搭建一个 nexus 私服用以共享内部发布的 jar 包。

有一种配置方式是用户都连接内部的 nexus 私服,这样所有的 jar 从用私服加速,这不是很理想。本文讨论的方式是内部 nexus 只用于发布内部的包,外部依赖仍从阿里云镜像获取。周边同事都配置得不太正确,正确的方式应该是这样:

    <mirror>
        <id>xx_id</id>
        <mirrorOf>xxx</mirrorOf>
        <name>xxx</name>
        <url>http://ip:8081/repository/yyyy-public</url>
    </mirror>
    
     <mirror>
        <id>nexus-aliyun</id>
        <mirrorOf>central</mirrorOf>
        <name>Nexus aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror>

要注意阿里云配置的 mirrorOf 不能是 *, 会导致私服不起作用,应该设置为 central 可以解决大部分包的加速,又可以和私服并存。

发布了211 篇原创文章 · 获赞 96 · 访问量 75万+

猜你喜欢

转载自blog.csdn.net/yucaifu1989/article/details/104552072