节俭包括:尚未定义类型

时间:2016-04-30 08:06:14

标签: thrift

我有两个节俭文件:common.thriftproto.thrift

含量:

common.thrift

namespace java ru.domain.myserv.common

struct MyStruct {
    1: i32 val
}

service MyServ {
    1: MyStruct myStruct,
    2: i32 val
}

proto.thrift

include "common.thrift"

namespace java ru.domain.myserv.proto

typedef ru.domain.myserv.common.MyServ MyServ

struct ProtoServ {
    1: MyServ myServ
}

接下来,我运行thrift生成器:

thrift -r -out ../java --gen java proto.thrift

我在控制台中看到错误:

[ERROR:/path/proto.thrift:8] (last token was 'ru.domain.myserv.common.MyServ') Type "ru.domain.myserv.common.MyServ" has not been defined.

我做错了什么?

1 个答案:

答案 0 :(得分:2)

天哪啊。

我必须指定

typedef common.MyServ MyServ

而不是

typedef ru.domain.myserv.common.MyServ MyServ

但那么namesapace是必要的吗?