方法emptyIntList()未定义 [英] The method emptyIntList() is undefined

查看:308
本文介绍了方法emptyIntList()未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Google Protobuf 的新手.尝试使用下面的 student.proto 文件进行播放.

I am new to Google Protobuf. Tried to play with it using below student.proto file.

syntax = "proto3";
package rld;

option java_package = "com.rld";
option java_outer_classname = "StudentDTO";

message Student {
    string name = 1;
    int32 roll = 2;  
    repeated int32 mark = 3; //Marks in various subjects
}

message StudentDatabase {
  repeated Student student = 1;
}

然后,我尝试使用下面的Protobuf编译器命令进行编译.我从此处下载了编译器.

Then I tried to compile it using below Protobuf compiler command. From here, I downloaded the compiler.

protoc -I=. --java_out=. ./student.proto

它成功编译并生成了 StudentDTO.java ,但有错误. 类中使用了两种方法' emptyIntList()'和' newIntList()',但未定义.

It compiled successfully and generated StudentDTO.java, but with errors. There are two methods 'emptyIntList()' and 'newIntList()' used inside the class, but they aren't defined.

现在我的问题是如何解决这些错误,或者我遗漏了什么?

Now my question is how to resolve those errors or am I missing something?

推荐答案

是新手,似乎我忘记了在更新 Protobuf编译器时更新 Google Protobuf运行时.两个版本必须匹配.

Being new, it seems I had forgotten to update Google Protobuf Runtime while updating Protobuf Compiler. Both the versions must match.

这是2个解决方案.

  1. Maven用户-在您的 POM 文件中包括以下依赖项.
  1. Maven Users - Include the following dependency in your POM file.

    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java</artifactId>
      <version>x.y.z</version>
    </dependency>

  1. 非Maven用户-在类路径中包含 protobuf-java-x.y.z.jar .
  1. Non Maven Users - Include the protobuf-java-x.y.z.jar in your classpath.

这篇关于方法emptyIntList()未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆