I have a working java
spring-boot
application that fetches a dependency from a gitlab
repository.
That works fine on a local mvn package
command. But as soon as I execute the mvn command inside a local docker
container, maven tries to resolve the spring artifacts also from my gitlab repository. Why?
Dockerfile
:
# syntax=docker/dockerfile:1
FROM maven:3.8.4-eclipse-temurin-11 as dependencies
COPY pom.xml .
COPY settings.xml .
RUN mvn --debug -U -B package -s settings.xml
pom.xml
:
<project>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.6</version>
<relativePath/>
</parent>
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://git.example.com/api/v4/projects/295/packages/maven</url>
</repository>
</repositories>
<dependencies>
...
</dependencies>
</project>
Result:
[INFO] Scanning for projects...
[DEBUG] Resolving artifact org.springframework.boot:spring-boot-starter-parent:pom:2.6.6 from [gitlab-maven (https://git.example.com/api/v4/projects/295/packages/maven, default, releases snapshots), central (https://repo.maven.apache.org/maven2, default, releases)]
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://git.example.com/api/v4/projects/295/packages/maven
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://git.example.com/api/v4/projects/295/packages/maven
[INFO] Downloading from gitlab-maven: https://git.example.com/api/v4/projects/295/packages/maven/org/springframework/boot/spring-boot-starter-parent/2.6.6/spring-boot-starter-parent-2.6.6.pom
settings.xml
:
<settings>
<servers>
<server>
<id>gitlab-maven</id>
<configuration>
<httpHeaders>
<property>
<name>Private-Token</name>
<value>xxx</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
</settings>
CodePudding user response:
It must have been any sort of caching issue. I removed docker configs, restarted the machine, now it works.
CodePudding user response:
Your query is why is resolve to your git repo right?
You are building the pom with your repo path, so it resolve to your repo
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://git.example.com/api/v4/projects/295/packages/maven</url>
</repository>
</repositories>
````