protobuf-maven-plugin 编译没有Grpc文件
时间: 2023-07-28 13:38:09 浏览: 90
如果您使用protobuf-maven-plugin编译时没有生成gRPC文件,可能是因为您没有在插件配置中添加grpc参数。请确保您的插件配置中包含以下参数:
```xml
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
<goal>test-compile</goal>
<goal>test-compile-custom</goal>
</goals>
</execution>
</executions>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.9.1:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.24.0:exe:${os.detected.classifier}</pluginArtifact>
<outputDirectory>${project.build.directory}/generated-sources/protobuf/java</outputDirectory>
<clearOutputDirectory>true</clearOutputDirectory>
<includeDirectories>
<include>src/main/protobuf</include>
</includeDirectories>
<protoSourceRoot>${project.basedir}/src/main/protobuf</protoSourceRoot>
<generateTestSources>false</generateTestSources>
<grpc>true</grpc>
</configuration>
</plugin>
```
请注意,此处的grpc参数设置为true。如果仍然无法生成gRPC文件,请检查您的proto文件是否正确,并确保插件配置文件中的路径和文件名正确。