Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.2k views
in Technique[技术] by (71.8m points)

grpc java - ERROR: PROTOC FAILED: google/protobuf/wrappers.proto: File not found. (Error in Maven build)

I was trying to build a grpc service using the following plugin. Seems like the plugin is not able to use protoc utility.

OS : MAC

Maven version : 3.6.3

Error :

[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]**

The plugin i am using is :

<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>
question from:https://stackoverflow.com/questions/65872523/error-protoc-failed-google-protobuf-wrappers-proto-file-not-found-error-in

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You are missing the protobuf-java dependency.

<dependencies>
??? <dependency>
????? <groupId>com.google.protobuf</groupId>
????? <artifactId>protobuf-java</artifactId>
????? <version>3.5.1-1</version>
??? </dependency>
??? ...
? </dependencies>

Here is how I use the plugin.

<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>

Then use the mvn protobuf:compile to generate the stubs. The reference is from the plugin repo at https://github.com/xolstice/protobuf-maven-plugin


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...