如何在Maven中访问多个存储库?

huangapple go评论69阅读模式
英文:

How to access more than one repo in maven?

问题

以下是您提供的内容的翻译部分:

原始配置部分:

Can someone clarify for me how I can access more than one repo in maven? I have a corporate mirror that is configured in settings.yml and it takes in all requests The problem is I need a jar file that is not in the mirror? If I switch it I lose all the other jars I need? Can someone explain what I need to do? If I add additional mirrors it only uses one of them at a time ... Every time I compile mvn clean install it just checks the one mirror and complains.

<mirrors>
    <mirror> <!--将所有请求发送到公共组-->
        <id>nexus</id>
        <mirrorOf>*</mirrorOf>
        <url>http://sl- quality.mycompany.com/nexus/content/groups/public/</url>
        <name>UK Central</name>
        <url>http://uk.maven.org/maven2</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
    <mirror> <!--将所有请求发送到公共组-->
        <id>ksqlDB</id>
        <mirrorOf>*</mirrorOf>
        <url>https://ksqldb-maven.s3.amazonaws.com/maven/</url>
    </mirror>
    <mirror> <!--将所有请求发送到公共组-->
        <id>confluent</id>
        <mirrorOf>*</mirrorOf>
        <url>https://jenkins-confluent-packages-beta-maven.s3.amazonaws.com/6.1.0-beta200715032424/1/maven/</url>
    </mirror>
</mirrors>
<activeProfiles>
    <!--使配置一直处于活动状态-->
    <activeProfile>nexus</activeProfile>
</activeProfiles>
<profiles>
    <profile>
        <id>nexus</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <repositories>
            <repository>

更新后的配置部分:

<mirrors>
    <mirror> <!--将所有请求发送到公共组-->
        <id>nexus</id>
        <mirrorOf>!ksqlDB, !confluent, *</mirrorOf>
        <url>http://sl-quality.mycompany.com/etc</url>
    </mirror>
    <mirror> <!--将所有请求发送到公共组-->
        <id>ksqlDB</id>
        <mirrorOf>!nexus,*</mirrorOf>
        <url>https://ksqldb-maven.s3.amazonaws.com/maven/</url>
    </mirror>
    <mirror> <!--将所有请求发送到公共组-->
        <id>confluent</id>
        <mirrorOf>!nexus, !ksqlDB, *</mirrorOf>
        <url>https://jenkins-confluent-packages-beta-maven.s3.amazonaws.com/6.1.0-beta200715032424/1/maven/</url>
    </mirror>
</mirrors>

pom.xml 

<repositories>
    <!-- jhipster-needle-maven-repository -->
    <repository>
        <id>ksqlDB</id>
        <name>ksqlDB</name>
        <url>https://ksqldb-maven.s3.amazonaws.com/maven/</url>
    </repository>
    <repository>
        <id>confluent</id>
        <name>Confluent</name>
        <url>https://jenkins-confluent-packages-beta-maven.s3.amazonaws.com/6.1.0-beta200715032424/1/maven/</url>
    </repository>
</repositories>

<pluginRepositories>
    <!-- jhipster-needle-maven-plugin-repository -->
    <pluginRepository>
        <id>ksqlDB</id>
        <url>https://ksqldb-maven.s3.amazonaws.com/maven/</url>
    </pluginRepository>
    <pluginRepository>
        <id>confluent</id>
        <url>https://jenkins-confluent-packages-beta-maven.s3.amazonaws.com/6.1.0-beta200715032424/1/maven/</url>
    </pluginRepository>
</pluginRepositories>

<ksqldb.version>0.11.0</ksqldb.version>
<!-- 用于编译的 Maven 属性 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

以上为翻译的内容,仅包含代码和配置部分。

英文:

Can someone clarify for me how I can access more than one repo in maven? I have a corporate mirror that is configured in settings.yml and it takes in all requests The problem is I need a jar file that is not in the mirror? If I switch it I lose all the other jars I need? Can someone explain what I need to do? If I add additional mirrors it only uses one of them at a time ... Every time I compile mvn clean install it just checks the one mirror and complains.

&lt;mirrors&gt;
    &lt;mirror&gt; &lt;!--Send all requests to the public group --&gt;
        &lt;id&gt;nexus&lt;/id&gt;
        &lt;mirrorOf&gt;*&lt;/mirrorOf&gt;
        &lt;url&gt;http://sl- quality.mycompany.com/nexus/content/groups/public/&lt;/url&gt;
    &lt;name&gt;UK Central&lt;/name&gt;
    &lt;url&gt;http://uk.maven.org/maven2&lt;/url&gt;
    &lt;mirrorOf&gt;central&lt;/mirrorOf&gt;--&gt;
    &lt;/mirror&gt;
    &lt;mirror&gt; &lt;!--Send all requests to the public group --&gt;
        &lt;id&gt;ksqlDB&lt;/id&gt;
        &lt;mirrorOf&gt;*&lt;/mirrorOf&gt;
        &lt;url&gt;https://ksqldb-maven.s3.amazonaws.com/maven/&lt;/url&gt;
    &lt;/mirror&gt;
     &lt;mirror&gt; &lt;!--Send all requests to the public group --&gt;
        &lt;id&gt;confluent&lt;/id&gt;
        &lt;mirrorOf&gt;*&lt;/mirrorOf&gt;
        &lt;url&gt;https://jenkins-confluent-packages-beta-maven.s3.amazonaws.com/6.1.0-beta200715032424/1/maven/&lt;/url&gt;
    &lt;/mirror&gt;
&lt;/mirrors&gt;
 &lt;activeProfiles&gt;
 &lt;!--make the profile active all the time --&gt;
    &lt;activeProfile&gt;nexus&lt;/activeProfile&gt;
&lt;/activeProfiles&gt;
&lt;profiles&gt;
    &lt;profile&gt;
        &lt;id&gt;nexus&lt;/id&gt;
       &lt;activation&gt;
            &lt;activeByDefault&gt;true&lt;/activeByDefault&gt;
        &lt;/activation&gt;
        &lt;repositories&gt;
            &lt;repository&gt;

UPDATE:

&lt;mirrors&gt;

    &lt;mirror&gt; &lt;!--Send all requests to the public group --&gt;
        &lt;id&gt;nexus&lt;/id&gt;
        &lt;mirrorOf&gt;!ksqlDB, !confluent, *&lt;/mirrorOf&gt;
        &lt;url&gt;http://sl-quality.mycompany.com/etc&lt;/url&gt;
        &lt;!--&lt;id&gt;UK&lt;/id&gt;
        &lt;name&gt;UK Central&lt;/name&gt;
        &lt;url&gt;http://uk.maven.org/maven2&lt;/url&gt;
        &lt;mirrorOf&gt;central&lt;/mirrorOf&gt;--&gt;
        &lt;/mirror&gt;
    &lt;mirror&gt; &lt;!--Send all requests to the public group --&gt;
        &lt;id&gt;ksqlDB&lt;/id&gt;
        &lt;mirrorOf&gt;!nexus,*&lt;/mirrorOf&gt;
        &lt;url&gt;https://ksqldb-maven.s3.amazonaws.com/maven/&lt;/url&gt;
   &lt;/mirror&gt;
   &lt;mirror&gt; &lt;!--Send all requests to the public group --&gt;
       &lt;id&gt;confluent&lt;/id&gt;
       &lt;mirrorOf&gt;!nexus, !ksqlDB, *&lt;/mirrorOf&gt;
       &lt;url&gt;https://jenkins-confluent-packages-beta-maven.s3.amazonaws.com/6.1.0-beta200715032424/1/maven/&lt;/url&gt;
  &lt;/mirror&gt;

</mirrors>

pom.xml

 &lt;repositories&gt;
       &lt;!-- jhipster-needle-maven-repository --&gt;
         &lt;repository&gt;
            &lt;id&gt;ksqlDB&lt;/id&gt;
            &lt;name&gt;ksqlDB&lt;/name&gt;
            &lt;url&gt;https://ksqldb-maven.s3.amazonaws.com/maven/&lt;/url&gt;
        &lt;/repository&gt;
        &lt;repository&gt;
            &lt;id&gt;confluent&lt;/id&gt;
            &lt;name&gt;Confluent&lt;/name&gt;
            &lt;url&gt;https://jenkins-confluent-packages-beta-maven.s3.amazonaws.com/6.1.0-beta200715032424/1/maven/&lt;/url&gt;
        &lt;/repository&gt;
    &lt;/repositories&gt;

    &lt;pluginRepositories&gt;
        &lt;!-- jhipster-needle-maven-plugin-repository --&gt;
        &lt;pluginRepository&gt;
            &lt;id&gt;ksqlDB&lt;/id&gt;
            &lt;url&gt;https://ksqldb-maven.s3.amazonaws.com/maven/&lt;/url&gt;
        &lt;/pluginRepository&gt;
        &lt;pluginRepository&gt;
            &lt;id&gt;confluent&lt;/id&gt;
            &lt;url&gt;https://jenkins-confluent-packages-beta-maven.s3.amazonaws.com/6.1.0-beta200715032424/1/maven/&lt;/url&gt;
        &lt;/pluginRepository&gt;
    &lt;/pluginRepositories&gt;

 &lt;ksqldb.version&gt;0.11.0&lt;/ksqldb.version&gt;
        &lt;!-- Maven properties for compilation --&gt;
        &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
        &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;

// This is all to get just

&lt;dependency&gt;
      &lt;groupId&gt;io.confluent.ksql&lt;/groupId&gt;
      &lt;artifactId&gt;ksqldb-api-client&lt;/artifactId&gt;
       &lt;version&gt;${ksqldb.version}&lt;/version&gt;
&lt;/dependency&gt;

答案1

得分: 1

因为您已经指定了这些内容是一切的镜像。

<mirrorOf>*</mirrorOf>

您不应该有3个都是一切的镜像。这没有任何意义。

您应该使用一些排除项。在这种情况下,这意味着“除了someRepo之外的所有内容”。

<mirrorOf>*,!someRepo</mirrorOf>

请参阅镜像设置指南

英文:

It's because you've specified these things are a mirror of everything.

&lt;mirrorOf&gt;*&lt;/mirrorOf&gt;

You shouldn't have 3 mirrors which are all a mirror of everything. That doesn't make any sense.

You should make use of some exclusions. In this case, this means "everything except someRepo".

&lt;mirrorOf&gt;*,!someRepo&lt;/mirrorOf&gt;

See Guide to Mirror Settings

huangapple
  • 本文由 发表于 2020年9月2日 20:18:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/63705368.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定