使用maven编译protobuf所需要的jar包
1. 安装配置maven
(1)下载maven http://maven.apache.org/ 版本:apache-maven-2.2.1
(2)添加maven到环境变量
(3)用mvn -version 查看是否成功
2. 下载protobuf
https://code.google.com/p/protobuf/downloads/list
Protocol Buffers 2.5.0 compiler -- Windows binary -> protoc.exe 编译使用
Protocol Buffers 2.5.0 full source -- C++, Java, Python -> 代码
3. 编译
(1) 解压Protocol Buffers 2.5.0 full source 到 C:softwareprotobuf-2.5.0
(2) 解压Protocol Buffers 2.5.0 compiler, 拷贝protoc.exe 到C:softwareprotobuf-2.5.0javasrc
(3)运行cmd 到C:softwareprotobuf-2.5.0java 执行 mvn package
note:
如果出现错误:
An Ant BuildException has occured: Execute failed: java.io.IOException: Cannot run program "..srcprotoc": CreateProcess error=2, The system c annot find the file specified
修改:C:softwareprotobuf-2.5.0javapom.xml
<mkdir dir="target/generated-sources" />
<exec executable="./src/protoc">