多个镜像的Maven设置 [英] maven settings for multiple mirrors

查看:59
本文介绍了多个镜像的Maven设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些个人项目,也有一些公司项目.公司项目将镜像的公司SVN存储库用于maven依赖项.我想以一种方式对我的settings.xml进行配置,以便首先根据我的公司镜像检查依赖项.仅当在此处(对于我的个人项目)未找到依赖项时,才应检查由公司存储库镜像的原始中央"存储库.这可能吗.以下是我现在拥有的代码段,但是在需要时它没有达到中央"存储库.谢谢.

I have a few personal projects and few corporate ones. The corporate projects use a mirrored corporate SVN repo for maven dependencies. I would like to configure my settings.xml in such a way that the dependencies are first checked against my corporate mirror. Only when the dependencies are not found here (for my personal projects) then it should check against the original "central" repo that is mirrored by my corporate repo. Is this possible. Below is a snippet of what I have right now but it doesn't hit the "central" repo when required. Thanks.

<servers>
    <server>
        <id>central-mirror</id>
        <username>myusername</username>
        <password>mypassword</password>
        <filePermissions>664</filePermissions>
        <directoryPermissions>775</directoryPermissions>
        <configuration></configuration>
    </server>
</servers>

<mirrors>
    <mirror>
        <id>central-mirror</id>
        <url>https://url.to.my/mirror</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
</mirrors>


<proxies>
    <proxy>
    <id>proxy</id>
    <active>true</active>
    <protocol>http</protocol>
    <host>my.corporate.proxy</host>
    <port>8080</port>
    <nonProxyHosts>localhost|*.my.corporate.proxy</nonProxyHosts>
</proxy>

推荐答案

好几次试验和错误之后,我终于弄清楚了该怎么做.我希望这会帮助许多其他人.以下是我更新的settings.xml.对于我Eclipse中的任何项目,maven首先尝试从公司镜像中下载库.只有在那里找不到它时,它才会从中央存储库中获取它.

Ok after some trial and error I finally figured out how to do this. I am hoping this will help out many others. Below is my updated settings.xml. For any project in my Eclipse, maven first tries to download libs from my corporate mirror. Only if it can't find it there, it gets it from central repo.

<servers>
    <server>
        <id>central-mirror</id>
        <username>myusername</username>
        <password>mypassword</password>
        <filePermissions>664</filePermissions>
        <directoryPermissions>775</directoryPermissions>
        <configuration></configuration>
    </server>
</servers>

<mirrors>
    <mirror>
        <id>central-mirror</id>
        <url>https://url.to.my/mirror</url>
        <mirrorOf>*,!central</mirrorOf>
    </mirror>
</mirrors>


<proxies>
    <proxy>
    <id>proxy</id>
    <active>true</active>
    <protocol>http</protocol>
    <host>my.corporate.proxy</host>
    <port>8080</port>
    <nonProxyHosts>localhost|*.my.corporate.proxy</nonProxyHosts>
</proxy>

<profiles>
  <profile>
    <activeByDefault>true</activeByDefault>
    <repositories>
        <repository>
            <id>central-mirror</id>
            <url>https://url.to.my/mirror</url>
        </repository>
    </repositories>
  </profile>
</profiles

这篇关于多个镜像的Maven设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆