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

Ubuntu下Maven编译gRPC proto文件报protoc未正常退出错误

gRPC Spring Boot示例项目构建失败问题记录

基础信息

  • 目标项目:grpc-spring-boot-example
  • 运行环境:Ubuntu 20.04 x86_64
  • 前置校验:项目中greeting.proto文件无语法错误,文件内容如下:
syntax = "proto3";

package com.techprimers.grpc;

option java_multiple_files = true;
option java_package = "com.techprimers.grpc";

service GreetingService {
  rpc greeting(GreetingRequest) returns (GreetingResponse) {
  }
}

message GreetingRequest {
  string message = 1;
}

message GreetingResponse {
  string message = 1;
}

故障表现

在项目目录下执行构建命令./mvnw clean install时,protobuf-maven-plugin 0.6.1在proto编译阶段报错:

  • 插件错误拉取了适配osx-x86_64(macOS Intel架构)平台的protoc可执行文件
  • Linux环境下直接运行该macOS平台二进制文件,触发Unterminated quoted string语法错误
  • 构建流程终止,终端抛出错误提示:protoc did not exit cleanly. Review output for more information

查阅同类问题资料未找到有效解决方案,完整构建日志如下:

anhtrt@des-1031:~/Documents/grpc-spring-boot-example/greeting-common$ ./mvnw clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Detecting the operating system and CPU architecture
[INFO] ------------------------------------------------------------------------
[INFO] os.detected.name: linux
[INFO] os.detected.arch: x86_64
[INFO] os.detected.version: 5.13
[INFO] os.detected.version.major: 5
[INFO] os.detected.version.minor: 13
[INFO] os.detected.release: ubuntu
[INFO] os.detected.release.version: 20.04
[INFO] os.detected.release.like.ubuntu: true
[INFO] os.detected.release.like.debian: true
[INFO] os.detected.classifier: linux-x86_64
[INFO] 
[INFO] ------------------< com.techprimers:greeting-common >-------------------
[INFO] Building greeting-common 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ greeting-common ---
[INFO] Deleting /home/anhtrt/Documents/grpc-spring-boot-example/greeting-common/target
[INFO] 
[INFO] --- protobuf-maven-plugin:0.6.1:compile (default) @ greeting-common ---
[INFO] Compiling 1 proto file(s) to /home/anhtrt/Documents/grpc-spring-boot-example/greeting-common/target/generated-sources/protobuf/java
[ERROR] PROTOC FAILED: /home/anhtrt/Documents/grpc-spring-boot-example/greeting-common/target/protoc-plugins/protoc-3.14.0-osx-x86_64.exe: 3: Syntax error: Unterminated quoted string

[ERROR] /home/anhtrt/Documents/grpc-spring-boot-example/greeting-common/src/main/proto/greeting.proto [0:0]: /home/anhtrt/Documents/grpc-spring-boot-example/greeting-common/target/protoc-plugins/protoc-3.14.0-osx-x86_64.exe: 3: Syntax error: Unterminated quoted string

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.428 s
[INFO] Finished at: 2022-06-15T09:46:26+07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile (default) on project greeting-common: protoc did not exit cleanly. Review output for more information. -> [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/MojoFailureException

内容的提问来源于stack exchange,提问作者Trần Tuấn Anh

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.29 22:33:01