如何使本地Nexus存储库成为更多公共存储库的代理 [英] How to make local Nexus repository be proxy for more public repoistories

查看:136
本文介绍了如何使本地Nexus存储库成为更多公共存储库的代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将Nexus设置为本地Maven存储库,并根据

I have set up Nexus as local maven repository, and updated the settings.xml according the the Guide.

如果可以从诸如 MavenCentral 之类的著名公共存储库中找到我的依赖项,则它会很好地工作.

It works very well if my dependencies can be found from the well-known public repositories like MavenCentral.

但是,如果需要从不太知名的存储库(如果我不想在我的项目pom.xml中定义任何存储库)中下载我的依赖项,则不会起作用 https://clojars.org/repo .

However, it does not work if my dependency needs to be downloaded from a not so well-known repository (if I don't want to define any repository in my project pom.xml) like https://clojars.org/repo.

如何配置Nexus或maven解决我的问题?

How could I configure the Nexus or maven to solve my problem?

我的maven settings.xml

My maven settings.xml

<?xml version="1.0" encoding="UTF-8"?>

<settings>

  <pluginGroups>
  </pluginGroups>

  <proxies>
  </proxies>

  <servers>
  </servers>

  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <repositories>
        <repository>
          <id>clojars</id>
          <name>Clojars repository</name>
          <url>https://clojars.org/repo</url>
        </repository>
      </repositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>

还有我的pom.xml:

And my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mycompany.app</groupId>
    <artifactId>my-app</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>my-app</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>com.flipkart.zjsonpatch</groupId>
            <artifactId>zjsonpatch</artifactId>
            <version>0.2.1</version>
        </dependency>
    </dependencies>
    <repositories>
    </repositories>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <compilerVersion>1.8</compilerVersion>
                    <source>1.8</source>
                    <target>1.8</target>
                    <!-- prevents endPosTable exception for maven compile -->
                    <useIncrementalCompilation>false</useIncrementalCompilation>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

推荐答案

您必须在Nexus存储库中添加代理存储库.创建完成后,您必须将这些新存储库添加到组公共存储库.您当前的settings.xml指向正确的URL.因此,现在您将能够从新的存储库中下载工件,并在Nexus中存储工件.

You have to add a proxy repository in Nexus repository. Once created, you must to add these new repository to the group Public Repositories. Your current settings.xml is pointing to the right url. So, now you will be able to download artifacts from the new repository storing artifacts in your Nexus.

这篇关于如何使本地Nexus存储库成为更多公共存储库的代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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