You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

将GitHub作为Maven仓库使用时创建Blob报错:404 Not Found

问题描述

我按以下步骤尝试将GitHub作为Maven仓库使用,执行mvn deploy -e -X时出现404错误,日志显示创建Blob失败,但本地文件确实存在,怀疑是不是文件夹未刷新导致的?

已执行操作步骤

  • 创建公开仓库: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

排查与解决方向

文件夹未刷新的概率极低,Maven在执行deploy阶段会确保文件写入磁盘后才触发后续操作。这个404错误更可能是GitHub端权限或配置问题,建议从以下几点排查:

  1. 确认目标分支存在
    插件配置的分支是refs/heads/mvn-repo,需要先在GitHub仓库手动创建mvn-repo分支,插件不会自动创建分支,这是这类404错误的常见原因。
  2. 替换认证方式
    GitHub已不再支持账号密码直接用于API操作,需改用个人访问令牌(PAT),令牌需勾选repo权限,替换settings.xml里的password字段为你的PAT。
  3. 检查仓库写入权限
    确保你的GitHub账号对目标仓库有写入权限,公开仓库的写入操作仍需授权。
  4. 清理本地目录后重试
    删除target/mvn-repo目录,执行mvn clean deploy -e -X,避免旧文件缓存干扰。
  5. 升级插件版本
    你使用的site-maven-plugin 0.11版本较旧,可能存在GitHub API兼容性问题,尝试升级到最新版本(如0.12)。

内容的提问来源于stack exchange,提问作者Keshavram Kuduwa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 05:53:25