Thrift环境搭建
步骤
下载thfift
https://thrift.apache.org/download
安装编译器
根据不同系统选择安装脚本 https://thrift.apache.org/docs/install/
注意事项
本机测试使用mac os
按照上面脚本分别下载安装 boost 、 libevent 编译thrift
可能会遇到的问题
需要提前安装 gcc
brew install gcc
提示 bison版本过低
brew install bison
export PATH="$(brew --prefix bison)/bin:$PATH"
最后编译thrift成功 但没有编译出java库?

所以最后 实际上 使用homebrew几秒钟安装完成?
brew install thrift
export PATH="$(brew --prefix thrift)/bin:$PATH"
编写.thrift 文件
通过IDL编写thrift types 和 service 这个service是需要被服务端实现 并且被客户端调用的
通过下面命令生成你所使用的语言代码
thrift --gen <language> <Thrift filename>
hello.thrift
namespace java top.lilixin.thrift.service
service GreetingService {
string sayHello(1:string name)
}
thrift -gen java hello.thrift
执行上面指令 得到 GreetingService.java文件
Last updated
Was this helpful?