最近开始使用google的序列化(protobuf),需要安装protobuf客户端将描述文件编译成java类; 下面是在mac的电脑上安装protobuf步骤,如下
下载源码
git clone https://github.com/google/protobuf
git checkout 版本号
安装 automake和 Libtool
brew install automake
brew install libtool
运行自动生成脚本
./autogen.sh
安装protobuf
./configure
make check
make
sudo make install
查看安装版本
protoc –version
maven生成protobuf的插件
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.5.0.Final</version>
</extension>
</extensions>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<extensions>true</extensions>
<configuration>
<!-- protoc -->
<protocArtifact>
com.google.protobuf:protoc:${protobuf-java.version}:exe:${os.detected.classifier}
</protocArtifact>
<!-- 是否清除输出目录 -->
<clearOutputDirectory>false</clearOutputDirectory>
<!-- java输出目录 -->
<outputDirectory>${basedir}/src/main/java</outputDirectory>
<!-- protoc-java -->
<pluginId>grpc-java</pluginId>
<pluginArtifact>
io.grpc:protoc-gen-grpc-java:${grpc-core.version}:exe:${os.detected.classifier}
</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>