以下是我使用 GitHub 作为 Maven 存储库已完成的步骤
https://github.com/keshavram-roomie/library
https://start.spring.io
并按原样生成了一个maven项目。maven-deploy-plugin
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<altDeploymentRepository>internal.repo::default::file://${project.build.directory}/mvn-repo</altDeploymentRepository>
</configuration>
</plugin>
site-maven-plugin
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.11</version>
<configuration>
<message>Maven artifacts for ${project.version}</message>
<!-- git commit message -->
<noJekyll>true</noJekyll>
<!-- disable webpage processing -->
<outputDirectory>${project.build.directory}/mvn-repo</outputDirectory>
<!-- matches distribution management repository url above -->
<branch>refs/heads/mvn-repo</branch>
<!-- remote branch name -->
<includes>
<include>**/*</include>
</includes>
<repositoryName>library</repositoryName>
<!-- github repo name -->
<repositoryOwner>keshavram-roomie</repositoryOwner>
<!-- github username -->
</configuration>
<executions>
<!-- run site-maven-plugin's 'site' target as part of the build's normal 'deploy' phase -->
<execution>
<goals>
<goal>site</goal>
</goals>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
~/.m2/settings.xml
<settings>
<servers>
<server>
<id>github</id>
<username>keshavram-roomie</username>
<password>password</password>
</server>
</servers>
</settings>
chmod 700 ~/.m2/settings.xml
mvn deploy -e -X
以下是最后一行错误
[DEBUG] Using 'github' server credentials
[DEBUG] Using basic authentication with username: keshavram-roomie
[DEBUG] Creating blob from /path/to/project/target/mvn-repo/com/roomie/library/0.0.1-SNAPSHOT/library-0.0.1-20230830.110614-2.jar.md5
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.692 s
[INFO] Finished at: 2023-08-30T16:36:24+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.github:site-maven-plugin:0.11:site (default) on project library: Error creating blob: Not Found (404) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.github:site-maven-plugin:0.11:site (default) on project library: Error creating blob: Not Found (404)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error creating blob: Not Found (404)
Caused by: org.eclipse.egit.github.core.client.RequestException: Not Found (404)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
它似乎正在尝试读取刚刚生成的文件,但找不到它。因为当我检查时,文件就在那里。难道是文件夹没有刷新?
首先检查这是否类似于这个答案,其中指出:
repositoryName
必须只是存储库的名称,在本例中为 library
。 (你做到了)关于第二点,“使用 Apache Maven 注册表”证实了:
您需要访问令牌来发布、安装和删除私有、内部和公共包。
您可以使用个人访问令牌(经典)对 GitHub Packages 或 GitHub API 进行身份验证。创建个人访问令牌(经典)时,您可以根据需要为令牌分配不同的范围。有关个人访问令牌(经典)的包相关范围的更多信息,请参阅“关于 GitHub Packages 的权限”。
要在 GitHub Actions 工作流程中对 GitHub Packages 注册表进行身份验证,您可以使用:
发布与工作流程存储库关联的包。GITHUB_TOKEN
- 一个个人访问令牌(经典),至少具有
范围来安装与其他私有存储库(read:packages
无法访问)关联的软件包。GITHUB_TOKEN
因此请仔细检查您的密码:它必须是令牌,而不是您实际的 GitHub 用户帐户密码。