如何使用关键字"include"在Thrift文件中定义的结构

zun*_*gnv 5 java communication thrift

我是Thrift的新手.我有以下问题:假设我在文件"Ex1.thrift"中定义了一个结构如下:

namespace java tut1
struct Address {
 1:string nameStreet,
 2:i32 idHouse
}
Run Code Online (Sandbox Code Playgroud)

我想在文件"Ex2.thrift"中使用struct Address,我该怎么做?我试过这种方式,但Thrift编译器不起作用:

include "Ex1.thrift"
namespace java tut2
struct Student {
 1:string name,
 2:i32 age,
 3:Address add
}

service ExampleService {
 list<Student> getListStudent()
}
Run Code Online (Sandbox Code Playgroud)

非常感谢你的回答.

gt5*_*050 13

在Ex2.thrift中使用地址时需要提供Ex1前缀

    include "Ex1.thrift"
    namespace java tut2
    struct Student {
    1:string name,
    2:i32 age,
    3:Ex1.Address add
    }

    service ExampleService {
    list<Student> getListStudent()
    }
Run Code Online (Sandbox Code Playgroud)

这适用于Thrift 0.8.0