Reputation: 719
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]
Upvotes: 0
Views: 5021
Reputation: 405
The tags do not affect the order at which maven uses repositories to fetch dependencies.
So the for maven central should be central, just for good practice.
However, your order is right but your links are not correct. you did not specify the central repository correctly. Try this instead:
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>maven2</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
For your artifactory, try with your browser if you can connect to https://swg-devops.com/artifactory . Try also with https://repo.maven.apache.org/maven2 and you should see how it should look like. When you have the correct link resolved you should be able to download the dependencies and maven automatically tries all the repositories from first to last to find the dependency.
Upvotes: 2