【发布时间】:2021-07-07 16:03:04
【问题描述】:
几天前,我为一个 java 库创建了一个 Github 包。 现在我想将 Github Packages 的依赖项添加到另一个 Maven 项目,但是我收到以下错误:
无法将工件 io.geilehner:storyblok-java-sdk:pom:1.0.1 从/到 github (https://maven.pkg.github.com/geilix10/) 传输:https://maven.pkg.github.com/geilix10/io/geilehner/storyblok-java-sdk/1.0.1/storyblok-java-sdk-1.0.1.pom 400 错误请求传输失败
我的~/.m2/settings.xml
<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>github</id>
<username>geilix10</username>
<password>ghp__ PERSONAL_ACCESS_TOKEN....</password>
</server>
</servers>
</settings>
我想要添加包的项目中的 pom.xml。
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/geilix10/</url>
</repository>
</repositories>
以及依赖本身:
<dependency>
<groupId>io.geilehner</groupId>
<artifactId>storyblok-java-sdk</artifactId>
<version>1.0.1</version>
</dependency>
我需要 pom.xml 中的存储库标记,因为稍后 GitHub Actions 应该构建这个项目,否则它将找不到包。 包链接:https://github.com/geilix10/storyblok-java-sdk/packages/716104?version=1.0.1
#编辑
将我的 settings.xml 调整为(按照建议)后:
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<activeProfiles>
<activeProfile>default</activeProfile>
</activeProfiles>
<servers>
<server>
<id>github</id>
<username>geilix10</username>
<password>TOKEN</password>
</server>
</servers>
<profiles>
<profile>
<id>default</id>
<repositories>
<repository>
<id>github</id>
<name>GitHub Apache Maven Packages</name>
<url>https://maven.pkg.github.com/geilix10/*</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>
还有我的 pom.xml:
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/geilix10/storyblok-java-sdk/</url>
</repository>
</repositories>
<dependency>
<groupId>io.geilehner</groupId>
<artifactId>storyblok-java-sdk</artifactId>
<version>1.0.1</version>
</dependency>
然后使用命令检索 Allen D 建议的包。我收到以下错误消息:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.1.2:get (default-cli) on project regiolix: Couldn't download artifact: org.eclipse.aether.resolution.DependencyResolutionException: Failed to read artifact descriptor for io.geilehner:storyblok-java-sdk:jar:1.0.1: Could not transfer artifact io.geilehner:storyblok-java-sdk:pom:1.0.1 from/to github (https://maven.pkg.github.com/geilix10/): Failed to transfer file https://maven.pkg.github.com/geilix10/io/geilehner/storyblok-java-sdk/1.0.1/storyblok-java-sdk-1.0.1.pom with status code 400 -> [Help 1]
【问题讨论】:
标签: maven github github-package-registry