如何编译 Apache Thrift 定义文件? [英] How can I compile an Apache Thrift definition file?
问题描述
我正在尝试编译一个 Apache Thrift 定义文件(在 Ubuntu 上).我不断收到错误消息:Could not open input file with realpath: Calculator.thrift
每当我在命令行中输入 thrift -r --gen java Calculator.thrift
时.我已经安装了 Thrift.我应该在哪里保存 .thrift 定义文件以便编译它们?
I'm trying to compile an Apache Thrift definition file (on Ubuntu). I keep getting the error message: Could not open input file with realpath: Calculator.thrift
whenever I enter thrift -r --gen java Calculator.thrift
into the command line. I have already installed Thrift. Where should I save .thrift definition files so that it will be possible to compile them?
推荐答案
在thrift安装自带的教程目录下,应该可以看到以下2个*.thrift
文件:
In the tutorial directory that comes with the thrift installation, you should see the following 2 *.thrift
files:
shared.thrift
tutorial.thrift
从同一个目录中,您应该能够从 thrift IDL 文件生成/编译如下:
From this same directory you should be able to generate/compile from the thrift IDL files as follows:
thrift -r --gen java ./tutorial.thrift
这应该会在教程目录中创建一个 gen-java
子目录.
This should create a gen-java
sub-directory in the tutorial directory.
Calculator.thrift
文件实际上并不存在,计算器服务在 tutorial.thrift
中定义.该错误试图告诉您它无法找到该文件,这是正确的,因为它实际上并不存在:)
The Calculator.thrift
file does not actually exist, the Calculator service is defined in tutorial.thrift
. The error is trying to tell you that it cant find the file, and rightly so, since it doesnt actually exist :)
这篇关于如何编译 Apache Thrift 定义文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!