使用google protobuf

在使用spring-data-redis的时候,发现它对象默认的序列化是使用JdkSerializationRedisSerializer,这样缓存信息比较多,故研究下google protobuf序列化处理。

1 下载 protoc-2.5.0-win32.zip 和 protobuf-2.5.0.zip 地址:

http://code.google.com/p/protobuf/downloads/list

读protobuf-2.5.0下readme.txt

2、在protoc-2.5.0-win32

找到protoc.exe,执行

G:\学习资料\protobuf\protoc-2.5.0-win32>protoc --java_out=src/main/java -I../pro
tobuf-2.5.0 ../protobuf-2.5.0/src/google/protobuf/descriptor.proto
G:\学习资料\protobuf\protoc-2.5.0-win32>protoc --java_out=src/main/java -Iprotoc
protoc/comment.proto
如果报错,比如说 No such file or directory 或者 Missing input file, 请检查-I 后面的路径和descriptor.proto名称是否拼写错了

源码中缺这个文件DescriptorProtos.java,生成后拷贝进去
添加后即可用maven打包。

附:
字段类型:
字节码原理:
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章