首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误: PROTOC失败: google/protobuf/wrappers.proto: File未找到。( Maven构建中出现错误)

错误: PROTOC失败: google/protobuf/wrappers.proto: File未找到。( Maven构建中出现错误)
EN

Stack Overflow用户
提问于 2021-01-24 15:37:07
回答 3查看 3.9K关注 0票数 0

我试图使用以下插件构建一个grpc服务。似乎插件无法使用protoc实用程序。

操作系统: MAC

Maven版本: 3.6.3

错误:

代码语言:javascript
复制
[ERROR] PROTOC FAILED: google/protobuf/wrappers.proto: File not found.
order-mgmt.proto: Import "google/protobuf/wrappers.proto" was not found or had errors.
order-mgmt.proto:7:16: "google.protobuf.StringValue" is not defined.

...
**[ERROR] Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile (default) on project OrderManagement-gRPC: protoc did not exit cleanly. Review output for more information. -> [Help 1]**

我使用的插件是:

代码语言:javascript
复制
<plugin>
            <groupId>org.xolstice.maven.plugins</groupId>
            <artifactId>protobuf-maven-plugin</artifactId>
            <version>0.6.1</version>
            <configuration>
                <!--suppress UnresolvedMavenProperty -->
                <protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact>
                <pluginId>grpc-java</pluginId>
                <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact> </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>compile-custom</goal>
                    </goals>
                </execution>
            </executions>
EN

Stack Overflow用户

回答已采纳

发布于 2021-01-24 17:22:25

您缺少了protobuf-java依赖项。

代码语言:javascript
复制
<dependencies>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java</artifactId>
      <version>3.5.1-1</version>
    </dependency>
    ...
  </dependencies>

下面是我如何使用插件。

代码语言:javascript
复制
<build>
  <extensions>
    <extension>
      <groupId>kr.motd.maven</groupId>
      <artifactId>os-maven-plugin</artifactId>
      <version>1.5.0.Final</version>
    </extension>
  </extensions>
  <plugins>
    <plugin>
      <groupId>org.xolstice.maven.plugins</groupId>
      <artifactId>protobuf-maven-plugin</artifactId>
      <version>0.5.1</version>
      <extensions>true</extensions>
      <configuration>
        <protocArtifact>com.google.protobuf:protoc:3.5.1-1:exe:${os.detected.classifier}</protocArtifact>
      </configuration>
      <executions>
        <execution>
          <goals>
            <goal>compile</goal>
            <goal>test-compile</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

然后使用mvn protobuf:compile生成存根。参考资料来自https://github.com/xolstice/protobuf-maven-plugin的插件回购

票数 2
EN
查看全部 3 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65872523

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档