一开始从官网下载的protobuf 3.3.0的最新版本,但是编译安装的时候有bug,回退到3.0稳定版本
tar.gz解压后安装
tar -zxvf xxx.tar.gz
./configure --prefix=/home/protobuf
make
make install
写proto文件
syntax="proto3"; package com.cmcc.protobuf; message Person { string username=1; int32 age=2; string sex=3; }
生成java文件
序列化写入磁盘文件并读取出来