google protobuf初学
来源:互联网 发布:mac中文官网 编辑:程序博客网 时间:2024/06/13 01:56
protocolbuffer是google 的提供的一种数据交换的格式,相对于xml和json,数据传递更小、更快。
eclipse下的使用步骤:
1.搭建maven编译环境
(1)java环境配置
(2)下载maven,下载地址:http://maven.apache.org/download.cgi
(3)配置maven环境,解压文件后,将D:\maven\bin添加到path路径下,cmd输入mvn -verson出现版本信息
2.下载源码,编译出proto-buf的jar包
下载protobuf-2.6.0.tar.gz和protoc-2.6.0-win32.zip,将protoc.ext复制到D:\protobuf-2.6.0\protobuf-2.6.0\src中,进入D:\protobuf- 2.6.0\protobuf-2.6.0\java\ 执行mvn package,在目录D:\protobuf-2.6.0\protobuf-2.6.0\java\target生成protobuf-java-2.6.0.jar
3.编写user.proc,切换到protoc.exe存放的目录,执行protoc -IPATH=d:\pro --java_out=d:\pro d:\pro\user.proc,执行protoc -h可查看相关参数的意思
4.简单例子
user.proc
package com.test;
message User {
required string name = 1;
optional int32 age = 2;
}
生成UserProc.java,使用如下:
UserProc.User.Builder userBuilder = UserProc.User.newBuilder();
UserProc.User user = userBuilder.setName("111").setAge(12).build();
System.out.println(user.getName() + " " + user.getAge());
- google protobuf初学
- google protobuf
- Google ProtoBuf
- protobuf (GOOGLE)
- google protobuf
- google protobuf
- 【google protobuf】
- google protobuf
- Google protobuf
- Google protoBuf
- Google Protobuf
- Google protobuf
- google protobuf 学习
- google ProtoBuf开发者指南
- google protobuf 源码解析
- google ProtoBuf开发者指南
- google ProtoBuf开发者指南
- google ProtoBuf开发者指南
- Android调用netty客户端出现编码问题
- Hibernate学习:主键生成策略
- Boost编译安装记录
- Android-ViewGroup的事件机制
- 一个简单的通用Makefile实现
- google protobuf初学
- Merge Intervals (Java)
- 一条sql 更新两张表的数据
- 用decodeFileDescriptor()来生成bimap比decodeFile()省内存
- android-新浪微博客户端开发-效果图以及讲解PPT(五)
- 面试技巧--->面向对象的思想示例
- Codeforces Round #290 (Div. 2)
- iOS和swift混编
- 线段树模板