Using multiple repositories in Maven

后端 未结 4 1073
逝去的感伤
逝去的感伤 2021-01-12 06:57

I have a project that uses an internal repository and the central repository. Is there a way I can configure the settings.xml such that I can use both instead of just one? W

4条回答
  •  醉梦人生
    2021-01-12 07:46

    There are a few of ways to do this.

    The best, IMO, is to have your local repository server act as a proxy for Maven Central. Both Nexus and Artifactory do this out of the box. If you're using Apache or another web server, you should switch.

    You can also update your settings exclude the target server from your mirror:

    *,!MyOtherRepository
    

    This works if you have multiple local repository servers, but I don't think you can exclude central this way: by default, Maven looks for artifacts in central, and your server acts as a stand-in for it.

    Which leaves explicit repository entries in your POMS, which reference the local repository. If your local repository just serves your artifacts, this might be the second-simplest thing to do (especially if you use a parent POM that holds the repository specification).

提交回复
热议问题