我正在尝试构建一些预先存在的 Java 代码,其中包括其传输层中的谷歌协议缓冲区。我正在使用的插件已包含在我的 pom 文件中,其中包含以下元素:
<plugin>
<groupId>com.github.igor-petruk.protobuf</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.3</version>
<executions>
<execution>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
我已经安装了protobuf版本 2.4.1,并且 protoc 可以通过命令行使用,并且我在我的 pom 中包含的 protobuf-java 的版本也是来自 com.google.protobuf 组的 2.4.1。正如我之前提到的,我必须使用这个技术堆栈,因为我正在使用现有的代码库,但是尽管有更新版本的 protobufs,但这并不是我遇到的问题。
问题是从 protoc 二进制文件(由上述 maven 插件调用)生成的代码没有实现从 protobuf 库中定义的父类的抽象函数,该 protobuf 库从 maven 导入到我的项目中。这是错误:
[ERROR] <generated java class from protoc> is not abstract and does not override abstract method getParserForType() in com.google.protobuf.MessageLite
我的假设是 protobuf 库存在一些配置错误,并且此函数 getParserForType 存在于其中一个库中,但不存在于另一个库中。