簡體   English   中英

Maven 正在嘗試從私有存儲庫安裝每個 jar

[英]Maven is trying to install every jar from a private repository

我在 S3 中有一個私有存儲庫,我用它來發布一個庫,然后我在另一個項目中使用它。

要發布,我有這個設置:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>

    <extensions>
        <extension>
            <groupId>com.allogy.maven.wagon</groupId>
            <artifactId>maven-s3-wagon</artifactId>
            <version>1.1.0</version>
        </extension>
    </extensions>
</build>

<distributionManagement>
    <repository>
        <id>projectx-aws-release</id>
        <name>ProjectX AWS Release Repository</name>
        <url>s3://projectx-support/maven2</url>
    </repository>
    <snapshotRepository>
        <id>projectx-aws-snapshots</id>
        <name>Projectx AWS Snapshot Repository</name>
        <url>s3://projectx-support/maven2</url>
    </snapshotRepository>
</distributionManagement>

然后,在使用該庫的應用程序上:

<build>
    ...

    <extensions>
        <extension>
            <groupId>com.allogy.maven.wagon</groupId>
            <artifactId>maven-s3-wagon</artifactId>
            <version>1.1.0</version>
        </extension>
    </extensions>
</build>

<repositories>
    <repository>
        <id>projectX-aws</id>
        <url>s3://projectX-support/maven2</url>
        <releases><enabled>true</enabled></releases>
        <snapshots><enabled>true</enabled></snapshots>
    </repository>
</repositories>

.circleci/settings.xml具有 S3 存儲庫的憑據:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <servers>
        <server>
            <id>projectx-aws</id>
            <username>....</username>
            <password>....</password>
        </server>
    </servers>
</settings>

當運行mvn --batch-mode --settings .circleci/settings.xml dependency:go-offline一些奇怪的事情發生。 它會快速下載一些依賴項:

mvn --batch-mode --settings .circleci/settings.xml dependency:go-offline
[INFO] Scanning for projects...
Downloading: http://repo.maven.apache.org/maven2/com/allogy/maven/wagon/maven-s3-wagon/1.1.0/maven-s3-wagon-1.1.0.pom
Downloaded: http://repo.maven.apache.org/maven2/com/allogy/maven/wagon/maven-s3-wagon/1.1.0/maven-s3-wagon-1.1.0.pom (7 KB at 47.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/com/allogy/allogy-maven-pom-oss/2.0/allogy-maven-pom-oss-2.0.pom
Downloaded: http://repo.maven.apache.org/maven2/com/allogy/allogy-maven-pom-oss/2.0/allogy-maven-pom-oss-2.0.pom (10 KB at 808.4 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/com/google/guava/guava/15.0/guava-15.0.pom
Downloaded: http://repo.maven.apache.org/maven2/com/google/guava/guava/15.0/guava-15.0.pom (7 KB at 508.8 KB/sec)
.
.
.
Downloading: http://repo.maven.apache.org/maven2/org/apache/apache/16/apache-16.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/apache/16/apache-16.pom (16 KB at 1879.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.10/maven-dependency-plugin-2.10.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.10/maven-dependency-plugin-2.10.jar (157 KB at 12014.5 KB/sec)

然后它顯示了這個:

[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building projectx 1.0.0-beta.2
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> maven-dependency-plugin:2.10:go-offline (default-cli) @ projectx >>>
[INFO] 
[INFO] --- maven-dependency-plugin:2.10:resolve-plugins (resolve-plugins) @ projectx ---

並下載更多的 deps:

Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-artifact/2.2.1/maven-artifact-2.2.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-artifact/2.2.1/maven-artifact-2.2.1.pom (2 KB at 171.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven/2.2.1/maven-2.2.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven/2.2.1/maven-2.2.1.pom (22 KB at 2431.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/11/maven-parent-11.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/11/maven-parent-11.pom (32 KB at 3516.6 KB/sec)
.
.
.
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.jar (29 KB at 4118.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.2/maven-jar-plugin-2.2.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.2/maven-jar-plugin-2.2.jar (27 KB at 3252.7 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.3/maven-install-plugin-2.3.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.3/maven-install-plugin-2.3.jar (23 KB at 2775.0 KB/sec)

但隨后它會嘗試從 S3 存儲庫下載 Maven Central 中應該存在的 jar 包:

[INFO] Plugin Resolved: copy-rename-maven-plugin-1.0.1.jar
Downloading: s3://projectx-support/maven2/com/coderplus/maven/plugins/copy-rename-maven-plugin/1.0.1/copy-rename-maven-plugin-1.0.1.pom
[INFO] File permissions: Private
[INFO] Logged in - projectx-support
[INFO] Downloading: s3://projectx-support/maven2/com/coderplus/maven/plugins/copy-rename-maven-plugin/1.0.1/copy-rename-maven-plugin-1.0.1.pom
[INFO] Logged off - projectx-support
[INFO] Transfers: 1 Time: 27ms Amount: 0 bytes Throughput: 0.000 bytes/s
Downloading: http://repo.maven.apache.org/maven2/com/coderplus/maven/plugins/copy-rename-maven-plugin/1.0.1/copy-rename-maven-plugin-1.0.1.pom
Downloaded: http://repo.maven.apache.org/maven2/com/coderplus/maven/plugins/copy-rename-maven-plugin/1.0.1/copy-rename-maven-plugin-1.0.1.pom (5 KB at 418.0 KB/sec)
Downloading: s3://projectx-support/maven2/org/sonatype/oss/oss-parent/9/oss-parent-9.pom
[INFO] File permissions: Private
[INFO] Logged in - projectx-support
[INFO] Downloading: s3://projectx-support/maven2/org/sonatype/oss/oss-parent/9/oss-parent-9.pom
[INFO] Logged off - projectx-support
[INFO] Transfers: 1 Time: 11ms Amount: 0 bytes Throughput: 0.000 bytes/s
Downloading: http://repo.maven.apache.org/maven2/org/sonatype/oss/oss-parent/9/oss-parent-9.pom
Downloaded: http://repo.maven.apache.org/maven2/org/sonatype/oss/oss-parent/9/oss-parent-9.pom (7 KB at 712.8 KB/sec)
Downloading: s3://projectx-support/maven2/org/apache/maven/maven-model/2.0.9/maven-model-2.0.9.jar
[INFO] File permissions: Private
[INFO] Logged in - projectx-support
[INFO] Downloading: s3://projectx-support/maven2/org/apache/maven/maven-model/2.0.9/maven-model-2.0.9.jar
[INFO] Logged off - projectx-support
[INFO] Transfers: 1 Time: 12ms Amount: 0 bytes Throughput: 0.000 bytes/s
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-model/2.0.9/maven-model-2.0.9.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-model/2.0.9/maven-model-2.0.9.jar (86 KB at 9475.0 KB/sec)
Downloading: s3://projectx-support/maven2/org/apache/maven/maven-project/2.0.9/maven-project-2.0.9.jar
[INFO] File permissions: Private
[INFO] Logged in - projectx-support
[INFO] Downloading: s3://projectx-support/maven2/org/apache/maven/maven-project/2.0.9/maven-project-2.0.9.jar
[INFO] Logged off - projectx-support
[INFO] Transfers: 1 Time: 12ms Amount: 0 bytes Throughput: 0.000 bytes/s
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-project/2.0.9/maven-project-2.0.9.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-project/2.0.9/maven-project-2.0.9.jar (119 KB at 11892.6 KB/sec)
Downloading: s3://projectx-support/maven2/org/apache/maven/maven-core/2.0.9/maven-core-2.0.9.jar

一段時間后,AWS 開始拋出Connection refused錯誤(可能是某些保護系統?),並且不會下載僅存在於 S3 存儲庫中的依賴項:

Downloading: s3://projectx-support/maven2/tech/projectx/projectxcommon/1.0.0-SNAPSHOT/maven-metadata.xml
[WARN] s3://projectx-support/maven2 - Connection refused
[INFO] Logged off - projectx-support
[WARNING] Could not transfer metadata tech.projectx:projectxcommon:1.0.0-SNAPSHOT/maven-metadata.xml from/to projectx-aws (s3://projectx-support/maven2): Could not connect to repository
[WARNING] Failure to transfer tech.projectx:projectxcommon:1.0.0-SNAPSHOT/maven-metadata.xml from s3://projectx-support/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of projectx-aws has elapsed or updates are forced. Original error: Could not transfer metadata tech.projectx:projectxcommon:1.0.0-SNAPSHOT/maven-metadata.xml from/to projectx-aws (s3://projectx-support/maven2): Could not connect to repository
Downloading: s3://projectx-support/maven2/tech/projectx/projectxcommon/1.0.0-SNAPSHOT/projectxcommon-1.0.0-SNAPSHOT.pom
[WARN] s3://projectx-support/maven2 - Connection refused
[INFO] Logged off - projectx-support

這會導致編譯失敗:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.929s
[INFO] Finished at: Wed Apr 18 16:03:19 UTC 2018
[INFO] Final Memory: 32M/1067M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project projectx: Could not resolve dependencies for project tech.projectx:projectx:jar:1.0.0-beta.2: Failed to collect dependencies for [tech.projectx:projectxcommon:jar:1.0.0-SNAPSHOT (compile), org.projectlombok:lombok:jar:1.16.20 (compile), org.springframework:spring-web:jar:5.0.5.RELEASE (compile), org.springframework.retry:spring-retry:jar:1.2.2.RELEASE (compile), com.fasterxml.jackson.core:jackson-databind:jar:2.9.5 (compile), org.kordamp.ikonli:ikonli-javafx:jar:2.1.1 (compile), org.kordamp.ikonli:ikonli-fontawesome5-pack:jar:2.1.1 (compile), net.harawata:appdirs:jar:1.0.1 (compile), io.sentry:sentry:jar:1.7.3 (compile), org.javassist:javassist:jar:3.22.0-CR2 (compile), junit:junit:jar:4.12 (test)]: Failed to read artifact descriptor for tech.projectx:projectxcommon:jar:1.0.0-SNAPSHOT: Could not transfer artifact tech.projectx:projectxcommon:pom:1.0.0-SNAPSHOT from/to projectx-aws (s3://projectx-support/maven2): Could not connect to repository: Couldn't initialize a SAX driver to create an XMLReader: SAX2 driver class org.apache.xerces.parsers.SAXParser not found -> [Help 1]

任何想法發生了什么? 這似乎是不確定的。 它伴隨着不應該對其產生任何影響的變化,盡管它似乎非常一致,因為重建似乎並沒有改變結果。 我確信這些憑據有效,因為它們在兩個項目中使用,一個正在工作,並且它們與該項目工作時使用的相同。

自從我從 Gradle 切換到 Maven 以來,這種情況一直在發生,但由於這是一個完全不同的系統,我認為這不是一個非常有用的比較。

當我在自己的計算機上運行mvn --batch-mode --settings .circleci/settings.xml dependency:go-offline install -e -X時,刪除 ~/.m2/repository 后,輸出如下所示: https: //gist.github.com/pupeno/da4f53a6e9673ff611909021306191a4#file-maven-local-machine-log當我在 CircleCI 中做同樣的事情時,它看起來是這樣的: https ://gist.github.com/pupeno/da4f53a6e9673ff6211940091130 -maven-circleci-log

列出存在的存儲庫時,請遵循如何向 Maven 詢問默認存儲庫列表? ,我看到這個:

<repositories>
    <repository>
        <id>projectx-aws</id>
        <url>s3://projectx-support/maven2</url>
        <layout>default</layout>
        <locations class="linked-hash-map">
            <entry>
                <string></string>
                <inputLocation>
                    <lineNumber>461</lineNumber>
                    <columnNumber>21</columnNumber>
                    <source>
                        <modelId>tech.projectx:projectx:1.0.0-beta.2</modelId>
                        <location>C:\Users\pupeno\Documents\projectx\code\projectx\pom.xml</location>
                    </source>
                </inputLocation>
            </entry>
            <entry>
                <string>id</string>
                <inputLocation>
                    <lineNumber>462</lineNumber>
                    <columnNumber>17</columnNumber>
                    <source reference="../../../entry/inputLocation/source"/>
                </inputLocation>
            </entry>
            <entry>
                <string>url</string>
                <inputLocation>
                    <lineNumber>463</lineNumber>
                    <columnNumber>18</columnNumber>
                    <source reference="../../../entry/inputLocation/source"/>
                </inputLocation>
            </entry>
        </locations>
        <releases>
            <enabled>true</enabled>
            <locations class="linked-hash-map">
                <entry>
                    <string></string>
                    <inputLocation>
                        <lineNumber>464</lineNumber>
                        <columnNumber>23</columnNumber>
                        <source reference="../../../../../locations/entry/inputLocation/source"/>
                    </inputLocation>
                </entry>
                <entry>
                    <string>enabled</string>
                    <inputLocation>
                        <lineNumber>465</lineNumber>
                        <columnNumber>26</columnNumber>
                        <source reference="../../../../../locations/entry/inputLocation/source"/>
                    </inputLocation>
                </entry>
            </locations>
        </releases>
        <snapshots>
            <enabled>true</enabled>
            <locations class="linked-hash-map">
                <entry>
                    <string></string>
                    <inputLocation>
                        <lineNumber>467</lineNumber>
                        <columnNumber>24</columnNumber>
                        <source reference="../../../../../locations/entry/inputLocation/source"/>
                    </inputLocation>
                </entry>
                <entry>
                    <string>enabled</string>
                    <inputLocation>
                        <lineNumber>468</lineNumber>
                        <columnNumber>26</columnNumber>
                        <source reference="../../../../../locations/entry/inputLocation/source"/>
                    </inputLocation>
                </entry>
            </locations>
        </snapshots>
    </repository>
    <repository>
        <id>central</id>
        <name>Central Repository</name>
        <url>https://repo.maven.apache.org/maven2</url>
        <layout>default</layout>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

s3://projectx-support/maven2/tech/projectx/projectxcommon/1.0.0-SNAPSHOT/maven-metadata.xml存在並包含以下內容:

<?xml version="1.0" encoding="UTF-8"?>
<metadata modelVersion="1.1.0">
  <groupId>tech.projectx</groupId>
  <artifactId>projectxcommon</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <versioning>
    <snapshot>
      <timestamp>20180418.113836</timestamp>
      <buildNumber>5</buildNumber>
    </snapshot>
    <lastUpdated>20180418113836</lastUpdated>
    <snapshotVersions>
      <snapshotVersion>
        <extension>jar</extension>
        <value>1.0.0-20180418.113836-5</value>
        <updated>20180418113836</updated>
      </snapshotVersion>
      <snapshotVersion>
        <extension>pom</extension>
        <value>1.0.0-20180418.113836-5</value>
        <updated>20180418113836</updated>
      </snapshotVersion>
    </snapshotVersions>
  </versioning>
</metadata>

我的應用程序的依賴樹如下所示:

> mvn dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< tech.projectx:projectx >------------------------
[INFO] Building projectx 1.0.0-beta.2
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.10:tree (default-cli) @ projectx ---
[INFO] tech.projectx:projectx:jar:1.0.0-beta.2
[INFO] +- tech.projectx:projectxcommon:jar:1.0.0-SNAPSHOT:compile
[INFO] |  +- org.bouncycastle:bcprov-jdk15on:jar:1.59:compile
[INFO] |  +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] |  +- org.hibernate.validator:hibernate-validator:jar:6.0.9.Final:compile
[INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] |  |  \- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] |  +- org.glassfish:javax.el:jar:3.0.1-b10:compile
[INFO] |  +- org.springframework:spring-context:jar:5.0.5.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-aop:jar:5.0.5.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-expression:jar:5.0.5.RELEASE:compile
[INFO] |  +- com.pubnub:pubnub-gson:jar:4.19.0:compile
[INFO] |  |  +- com.squareup.retrofit2:retrofit:jar:2.3.0:compile
[INFO] |  |  +- com.squareup.okhttp3:okhttp:jar:3.9.1:compile
[INFO] |  |  |  \- com.squareup.okio:okio:jar:1.13.0:compile
[INFO] |  |  +- com.squareup.okhttp3:logging-interceptor:jar:3.9.1:compile
[INFO] |  |  +- com.google.code.gson:gson:jar:2.8.2:compile
[INFO] |  |  \- com.squareup.retrofit2:converter-gson:jar:2.3.0:compile
[INFO] |  +- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.5:compile
[INFO] |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.5:compile
[INFO] |  \- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.5:compile
[INFO] +- org.projectlombok:lombok:jar:1.16.20:compile
[INFO] +- org.springframework:spring-web:jar:5.0.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:5.0.5.RELEASE:compile
[INFO] |  \- org.springframework:spring-core:jar:5.0.5.RELEASE:compile
[INFO] |     \- org.springframework:spring-jcl:jar:5.0.5.RELEASE:compile
[INFO] +- org.springframework.retry:spring-retry:jar:1.2.2.RELEASE:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.5:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] |  \- com.fasterxml.jackson.core:jackson-core:jar:2.9.5:compile
[INFO] +- org.kordamp.ikonli:ikonli-javafx:jar:2.1.1:compile
[INFO] |  \- org.kordamp.ikonli:ikonli-core:jar:2.1.1:compile
[INFO] +- org.kordamp.ikonli:ikonli-fontawesome5-pack:jar:2.1.1:compile
[INFO] +- net.harawata:appdirs:jar:1.0.1:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] |  \- net.java.dev.jna:jna-platform:jar:4.5.0:compile
[INFO] |     \- net.java.dev.jna:jna:jar:4.5.0:compile
[INFO] +- io.sentry:sentry:jar:1.7.3:compile
[INFO] +- org.javassist:javassist:jar:3.22.0-CR2:compile
[INFO] \- junit:junit:jar:4.12:test
[INFO]    \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.188 s
[INFO] Finished at: 2018-04-23T20:38:39+01:00
[INFO] ------------------------------------------------------------------------

我的.cicleci\\config.yml文件如下所示:

# Java Gradle CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-java/ for more details
#
version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/jdk8:0.1.1

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # - image: circleci/postgres:9.4

    working_directory: ~/repo

    environment:
      # Customize the JVM maximum heap limit
      JVM_OPTS: -Xmx3200m
      TERM: dumb

    steps:
       - checkout

       - run: apt-get update

       - run: apt-get install --assume-yes maven

       - restore_cache:
           key: projectx-{{ checksum "pom.xml" }}

       - run: mvn --batch-mode --settings .circleci/settings.xml dependency:go-offline install -e -X

       - save_cache:
           paths:
             - ~/.m2
           key: projectx-{{ checksum "pom.xml" }}

       - run: mvn --batch-mode --settings .circleci/settings.xml test

我已為此存儲桶啟用日志記錄,其中一個條目如下所示(預期為 404):

https://gist.github.com/pupeno/da4f53a6e9673ff611909021306191a4#file-2018-04-23-21-10-39-7467973073c586b9

這些是對maven-metadata.xml的最后 3 次訪問:

可能的主要問題是對Amazon S3存儲庫的請求過多。

通過分析日志,我們可以看到在 1-3 秒的短時間內從Amazon S3下載文件的請求超過 120 個:

  • Maven 正在下載Amazon S3不存在的人工制品,然后從Maven Central下載它,對Amazon S3那些請求是無用的
  • 每次下載都需要登錄和注銷請求,這很奇怪!
  • 最后 40 個請求連接被拒絕
  • 最后 40 個請求沒有[INFO] Logged in -他們的projectx-support 聲明,所以可能在短時間內登錄有一些限制?

為了解決這個問題,至少有兩種解決方案:

  1. 強制 maven首先Maven Central下載人工制品,然后從Amazon S3 ,以減少對Amazon S3請求。 這是一個很好的解決方案,但請記住,如果您有更多的人工制品只能從Amazon S3下載,您將遇到同樣的問題!

    默認情況下, Maven Central最后在庫中,首先從建立最高優先級,下載Maven Center ,我們必須手動添加它在我們的資料庫第一個位置,因為庫的順序也將決定的存儲庫訪問的順序。 來源):

     <repositories> <repository> <id>central</id> <name>Central Repository</name> <url>https://repo.maven.apache.org/maven2</url> <layout>default</layout> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>projectX-aws</id> <url>s3://projectX-support/maven2</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories>
  2. 找到一種方法來更改Amazon S3存儲庫上的IP請求限制。 此解決方案將始終有效,但您的 Amazon S3 將收到許多無用的請求。

所以解決問題的最好方法是將這兩種解決方案混合使用。 :)

問題是 Maven 本身定義的 Maven Central 在超級 POM中總是排在存儲庫順序的最后,因此,projectx 的 S3 存儲庫受到許多失敗的請求的影響,最終 AWS S3 在projectxcommon之前暫時阻止了客戶端可以下載jar包。

在 S3 存儲庫之前使用 Maven Central 的唯一方法是在projectx-aws存儲庫之前的pom.xml手動定義它:

<repositories>
    <repository>
        <id>central</id>
        <name>Central Repository</name>
        <url>http://repo.maven.apache.org/maven2</url>
        <layout>default</layout>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>projectX-aws</id>
        <url>s3://projectX-support/maven2</url>
        <releases><enabled>true</enabled></releases>
        <snapshots><enabled>true</enabled></snapshots>
    </repository>
</repositories>

有關設置多個存儲庫及其順序的更多信息,請訪問:

Stack Overflow 中的一些答案提到了字母順序。 至少在 Maven 3 中這是不正確的,只有定義它們的順序才重要。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM