我使用maven protobuf插件生成grpc源代码,效果很好
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
<protocExecutable>/usr/bin/protoc</protocExecutable>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
然后我删除了 maven 中的插件pom.xml
并将代码复制到具有相同结构的源代码文件夹中,并删除了该target
文件夹(其中包含上面生成的源代码)。但是当我抛出错误时mvn clean install
error: not found: type BuilderParent
// many similar errors like this
但是在 IDE(IntelliJ IDEA)中它可以成功构建,但mvn clean install
不能。
在目标生成的源文件夹中使用和复制到src
源文件夹有什么不同吗?