0

I want to download 'standard' jars like Spring framework from central maven repository, but proprietary license jars from our custom maven repository (Artifactory) repo. I've setup the pom.xml file this way:

    <repositories>
    <repository>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>central</id>
        <name>maven2</name>
        <url>https://repo.maven.apache.org/maven2</url>
    </repository>   
    <repository>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>2</id>
        <name>Artifactory</name>
        <url>https://na.artifactory.swg-devops.com/artifactory/gbs-ic2esprint-bluecost-libs-maven-virtual</url>
    </repository>
</repositories>  

It's not working the way I want it. Here is what I get now:

    [INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building SpreadSheetUploadWeb 1.0
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: https://repo.maven.apache.org/maven2/com/fasterxml/jackson/core/jackson-databind/1.9.10/jackson-databind-1.9.10.pom
[INFO] Downloading: https://na.artifactory.swg-devops.com/artifactory/gbs-ic2esprint-bluecost-libs-maven-virtual/com/fasterxml/jackson/core/jackson-databind/1.9.10/jackson-databind-1.9.10.pom
[INFO] Downloading: http://repo.spring.io/ext-release-local/com/fasterxml/jackson/core/jackson-databind/1.9.10/jackson-databind-1.9.10.pom
[INFO] Downloading: http://repo.spring.io/milestone/com/fasterxml/jackson/core/jackson-databind/1.9.10/jackson-databind-1.9.10.pom
[INFO] Downloading: http://repo.spring.io/snapshot/com/fasterxml/jackson/core/jackson-databind/1.9.10/jackson-databind-1.9.10.pom
[INFO] Downloading: https://repo.maven.apache.org/maven2/com/fasterxml/jackson/core/jackson-annotations/1.9.10/jackson-annotations-1.9.10.pom
[INFO] Downloading: https://na.artifactory.swg-devops.com/artifactory/gbs-ic2esprint-bluecost-libs-maven-virtual/com/fasterxml/jackson/core/jackson-annotations/1.9.10/jackson-annotations-1.9.10.pom
[INFO] Downloading: https://repo.maven.apache.org/maven2/com/fasterxml/jackson/core/jackson-core/1.9.10/jackson-core-1.9.10.pom
[INFO] Downloading: https://na.artifactory.swg-devops.com/artifactory/gbs-ic2esprint-bluecost-libs-maven-virtual/com/fasterxml/jackson/core/jackson-core/1.9.10/jackson-core-1.9.10.pom
[INFO] Downloading: https://repo.maven.apache.org/maven2/com/ibm/db2/jcc/db2jcc_license_cisuz/10.5.9/db2jcc_license_cisuz-10.5.9.pom
[INFO] Downloading: https://na.artifactory.swg-devops.com/artifactory/gbs-ic2esprint-bluecost-libs-maven-virtual/com/ibm/db2/jcc/db2jcc_license_cisuz/10.5.9/db2jcc_license_cisuz-10.5.9.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.403 s
[INFO] Finished at: 2018-05-04T07:47:47-06:00
[INFO] Final Memory: 17M/153M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project SpreadSheetUploadWeb: Could not resolve dependencies for project SpreadSheetUploadWeb:SpreadSheetUploadWeb:jar:1.0: Failed to collect dependencies at org.springframework.boot:spring-boot-starter-thymeleaf:jar:1.4.3.RELEASE -> org.springframework.boot:spring-boot-starter-web:jar:1.4.3.RELEASE -> com.fasterxml.jackson.core:jackson-databind:jar:1.9.10: Failed to read artifact descriptor for com.fasterxml.jackson.core:jackson-databind:jar:1.9.10: Could not transfer artifact com.fasterxml.jackson.core:jackson-databind:pom:1.9.10 from/to 2 (https://na.artifactory.swg-devops.com/artifactory/gbs-ic2esprint-bluecost-libs-maven-virtual): Access denied to https://na.artifactory.swg-devops.com/artifactory/gbs-ic2esprint-bluecost-libs-maven-virtual/com/fasterxml/jackson/core/jackson-databind/1.9.10/jackson-databind-1.9.10.pom. Error code 401, Unauthorized -> [Help 1]
[ERROR]
4

1 回答 1

2

标签不影响 maven 使用存储库获取依赖项的顺序。

所以 for maven central 应该是中心的,只是为了良好的实践。

但是,您的订单是正确的,但您的链接不正确。您没有正确指定中央存储库。试试这个:

<repository>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>central</id>
            <name>maven2</name>
            <url>https://repo.maven.apache.org/maven2</url>
</repository>  

对于您的工件,如果您可以连接到https://swg-devops.com/artifactory,请尝试使用您的浏览器。也可以尝试使用https://repo.maven.apache.org/maven2,你应该会看到它应该是什么样子。当您解析了正确的链接后,您应该能够下载依赖项,并且 maven 会自动从头到尾尝试所有存储库以找到依赖项。

于 2018-05-04T10:47:44.197 回答