在 LoongArch64 (loong64) 龙芯电脑上编译 Maven 项目缺失依赖处理方案

前景提要

环境

debian-14:~# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux forky/sid"
NAME="Debian GNU/Linux"
VERSION_CODENAME=forky
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
debian-14:~# 
debian-14:~# uname -a
Linux debian-14 7.1.3+deb14-loong64 #1 SMP PREEMPT Debian 7.1.3-1 (2026-07-04) loongarch64 GNU/Linux
debian-14:~# 
debian-14:~# mvn -v
Apache Maven 3.9.16 (2bdd9fddda4b155ebf8000e807eb73fd829a51d5)
Maven home: /srv/apache-maven-3.9.16
Java version: 17.0.19, vendor: Loongson, runtime: /srv/jdk-17.0.19
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "7.1.3+deb14-loong64", arch: "loongarch64", family: "unix"
debian-14:~# 

问题

源码:GitHub - alibaba/nacos: an easy-to-use dynamic service discovery, configuration and service management platform for building AI cloud native applications. · GitHub

标签:3.2.3

说明:https://maven.loongnix.cn/loongarch/maven/io/grpc/protoc-gen-grpc-java/ 中,没有 1.78.0 版本

[ERROR] Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile-custom (default) on project nacos-consistency: Unable to resolve artifact: Missing:
[ERROR] ----------
[ERROR] 1) io.grpc:protoc-gen-grpc-java:exe:linux-loongarch_64:1.78.0
[ERROR] 
[ERROR]   Try downloading the file manually from the project website.
[ERROR] 
[ERROR]   Then, install it using the command: 
[ERROR]       mvn install:install-file -DgroupId=io.grpc -DartifactId=protoc-gen-grpc-java -Dversion=1.78.0 -Dclassifier=linux-loongarch_64 -Dpackaging=exe -Dfile=/path/to/file
[ERROR] 
[ERROR]   Alternatively, if you host your own repository you can deploy the file there: 
[ERROR]       mvn deploy:deploy-file -DgroupId=io.grpc -DartifactId=protoc-gen-grpc-java -Dversion=1.78.0 -Dclassifier=linux-loongarch_64 -Dpackaging=exe -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
[ERROR] 
[ERROR]   Path to dependency: 
[ERROR]         1) com.alibaba.nacos:nacos-consistency:jar:3.2.2
[ERROR]         2) io.grpc:protoc-gen-grpc-java:exe:linux-loongarch_64:1.78.0
[ERROR] 
[ERROR] ----------
[ERROR] 1 required artifact is missing.
[ERROR] 
[ERROR] for artifact: 
[ERROR]   com.alibaba.nacos:nacos-consistency:jar:3.2.2
[ERROR] 
[ERROR] from the specified remote repositories:
[ERROR]   nexus-settings (http://172.25.25.62:48081/repository/maven-public/, releases=true, snapshots=false)
[ERROR] 
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :nacos-consistency

解决方案

service@loongnix.cn 发送邮件,说明情况,见:支持 · 文档

收到回复

使用方案

虽然上述错误信息中,提示了可以使用 Maven 命令可以将依赖安装到本地,但是推荐大家使用 Maven 私有仓库

上传 Maven 私有仓库:

 xuxiaowei@172  ~/Downloads  cat settings.xml
<?xml version="1.0" encoding="UTF-8"?>

<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>maven-loong64-hosted</id>
      <username>用户名</username>
      <password>密码</password>
    </server>
  </servers>

</settings>
 xuxiaowei@172  ~/Downloads  
# deploy:deploy-file:发布
# -s settings.xml:指定 Maven settings.xml 文件位置,用于配置 Maven 发布时使用的用户名、密码
# -DrepositoryId=maven-loong64-hosted:Maven settings.xml 中 Maven 仓库的 ID
# -Durl=http://172.25.25.62:48081/repository/maven-loong64-hosted/:Maven 仓库地址

mvn deploy:deploy-file \
  -DgroupId=io.grpc \
  -DartifactId=protoc-gen-grpc-java \
  -Dversion=1.78.0 \
  -Dclassifier=linux-loongarch_64 \
  -Dpackaging=exe \
  -Dfile=./protoc-gen-grpc-java-1.78.0-linux-loongarch_64.exe \
  -s settings.xml \
  -DrepositoryId=maven-loong64-hosted \
  -Durl=http://172.25.25.62:48081/repository/maven-loong64-hosted/

使用效果

maven-loong64-hosted 仓库:

  1. Type(仓库类型)hosted 宿主仓库
  2. Version policy(版本策略):Mixed 包含 Release 正式版、Snapshot 快照版

maven-public 仓库:

  1. Type(仓库类型)group 分组仓库,包含了 maven-loong64-hosted 仓库

强烈建议 使用 -U 强制下载,否则由于 Maven 仓库机制的问题,存在近期产生的 _remote.repositoriesprotoc-gen-grpc-java-1.78.0-linux-loongarch_64.exe.lastUpdated 文件,不会下载远端仓库中新增的依赖,当然不使用 -U 参数,手动删除 _remote.repositoriesprotoc-gen-grpc-java-1.78.0-linux-loongarch_64.exe.lastUpdated 文件 等文件,也可以达到 -U 效果,不过太麻烦了

debian-14:~# cat /srv/apache-maven-repo/io/grpc/protoc-gen-grpc-java/1.78.0/_remote.repositories 
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
#Thu Jul 23 19:49:01 CST 2026
protoc-gen-grpc-java-1.78.0.pom>nexus-settings=
debian-14:~#
debian-14:~# cat /srv/apache-maven-repo/io/grpc/protoc-gen-grpc-java/1.78.0/protoc-gen-grpc-java-1.78.0-linux-loongarch_64.exe.lastUpdated
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
#Thu Jul 23 19:49:01 CST 2026
http\://172.25.25.62\:48081/repository/maven-public/.lastUpdated=1784807341323
http\://172.25.25.62\:48081/repository/maven-public/.error=
debian-14:~# 

-U 命令并非 Snapshot 快照版专属参数