我创建了一个保存到gitlab项目中的maven项目(PROJECT_A)。通过管道,我将这个项目发布到gitlab maven存储库中。这里是settings.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<servers>
<server>
<id>gitlab-maven</id>
<configuration>
<httpHeaders>
<property>
<name>Job-Token</name>
<value>${env.CI_JOB_TOKEN}</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
</settings>这是对pom.xml中的存储库的引用
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/PROJECT_A_ID/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/PROJECT_A_ID/packages/maven</url>
</repository>
<snapshotRepository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/PROJECT_A_ID/packages/maven</url>
</snapshotRepository>
</distributionManagement>maven jar被用作对另一个项目(PROJECT_B)的PROJECT_A依赖项。在后一个项目的pom.xml中,我声明了发布jar的存储库引用,这里是代码
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/PROJECT_A_ID/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/PROJECT_A_ID/packages/maven</url>
</repository>
<snapshotRepository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/PROJECT_A_ID/packages/maven</url>
</snapshotRepository>
</distributionManagement>如果我在本地运行这个项目,一切正常,依赖项被下载下来,我可以将它用到PROJECT_B中。
[ERROR] Failed to execute goal on project cost-center: Could not resolve dependencies for project com.phatedeveloper:cost-center:jar:0.0.1: Could not find artifact com.phatedeveloper:pbm-dto-library:jar:1.0-SNAPSHOT in gitlab-maven (https://gitlab.com/api/v4/projects/20364942/packages/maven) -> [Help 1]发布于 2021-02-19 05:49:09
我建议将存储库设置为基于组ID在项目之间共享。
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://code.siemens.com/api/v4/groups/GROUP_ID/-/packages/maven</url>
</repository>
</repositories>https://stackoverflow.com/questions/63291778
复制相似问题