Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List<Integer>类型不支持 #18

Closed
xbase opened this issue May 27, 2015 · 5 comments
Closed

List<Integer>类型不支持 #18

xbase opened this issue May 27, 2015 · 5 comments

Comments

@xbase
Copy link

xbase commented May 27, 2015

定义如下:
@protobuf
private List intList;

报错如下:
Class must has default constructor method with no parameters.

原始类型的数组或者list不支持?

@xiemalin
Copy link
Contributor

你这个错误应该pojo对象必须要提供默认构造函数

@xbase
Copy link
Author

xbase commented May 27, 2015

恩 原始类型,比如:Integer 是没有默认构造函数,
@protobuf
private List intList;
这样的字段,应该怎么定义呢?

@xiemalin
Copy link
Contributor

你这种情况,指定fieldType即可,如下:
@protobuf(fieldType = FieldType.INT32, order = 1, required = false)
public List<Integer> list1;

@xbase
Copy link
Author

xbase commented May 27, 2015

定义字段如下:
@protobuf(fieldType = FieldType.INT32, order = 4, required = false)
private List list;
生成的proto文件内容如下:
optional int32 list=4;

以上只列出了出错的字段。
可以加您的QQ吗,关于Jprotobuf,还有一些问题想要咨询您。

@xiemalin
Copy link
Contributor

你留一个QQ号给我吧

@xiemalin xiemalin reopened this May 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants