Protocol Buffer的安装与使用

Eave 2018.03.20

Google Protocol Buffer( 简称 Protobuf) 是 Google 公司内部的混合语言数据标准,目前已经正在使用的有超过 48,162 种报文格式定义和超过 12,183 个 .proto 文件。他们用于 RPC 系统和持续数据存储系统。

Protocol Buffers 是一种轻便高效的结构化数据存储格式,可以用于结构化数据串行化,或者说序列化。它很适合做数据存储或 RPC 数据交换格式。可用于通讯协议、数据存储等领域的语言无关、平台无关、可扩展的序列化结构数据格式。目前提供了 C++、Java、Python 三种语言的 API。

一、下载Protocol Buffer

下载地址:https://github.com/google/protobuf/releases

wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-all-3.5.1.tar.gz

二、编译Protocol Buffer

tar -zxf protobuf-all-3.5.1.tar.gz
./configure --prefix=/usr/local/protobuf
make && make install

三、下载Protocol Buffer Jar包

下载地址:http://mvnrepository.com/artifact/com.google.protobuf/protobuf-java

wget http://central.maven.org/maven2/com/google/protobuf/protobuf-java/3.5.1/protobuf-java-3.5.1.jar
/usr/local/protobuf/bin/protoc -I=./ --java_out=./ ./LogonReqMessage.proto