新建一個maven項目,先下載maven依賴 http://thrift.apache.org/downloadhtml
<dependency> <groupId>org.apache.thrift</groupId> <artifactId>libthrift</artifactId> <version>0.11.0</version> </dependency>
再安裝須要的工具 http://thrift.apache.org/docs/install/os_xjava
個人是MacBook Pro,按照要求,git
安裝thrift的工具依賴boost庫github
下載地址:www.boost.org,找到最新的版本下載,apache
下載以後解壓,而後用cmd模式進入到解壓文件夾的根目錄。bootstrap
執行命令xcode
./bootstrap.sh sudo ./b2 threading=multi address-model=64 variant=release stage install
若是出現missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun錯誤,
先執行ruby
xcode-select --install
安裝thrift的工具依賴libevent庫bash
下載地址:http://libevent.org,找一個穩定版本下載,curl
下載以後解壓,而後用cmd模式進入到解壓文件夾的根目錄。
執行命令:
./configure --prefix=/usr/local make sudo make install
make的時候出現 fatal error: 'openssl/bio.h' file not found
這是因爲mac默認安裝了openssl可是沒有安裝對應的include頭文件和lib庫,故這裏使用homebrew(參考https://brew.sh/index_zh-cn.html)來安裝最新的openssl
先安裝homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
再用homebrew安裝openssl(xcode要是最新版本的才能安裝):
brew install openssl brew link openssl --froce ln -s /usr/local/opt/openssl/bin/openssl /usr/local/bin/openssl ln -s /usr/local/opt/openssl/include/openssl /usr/local/include/openssl ln -s /usr/local/opt/openssl/lib/libssl.a /usr/local/lib/libssl.a ln -s /usr/local/opt/openssl/lib/libcrypto.a /usr/local/lib/libcrypto.a
而後從新運行 make 和 sudo make install 命令來安裝libevent
安裝Apache Thrift
下載最新版本的thrift 0.11,下載地址:http://archive.apache.org/dist/thrift/
解壓下載的文件,進入該目錄,運行如下腳本
./configure --prefix=/usr/local/ --with-boost=/usr/local --with-libevent=/usr/local
make sudo make install
若是報錯error: Bison version 2.5 or higher must be installed on the system!
運行thrift -version 命令查看thrift版本便可