使用Thrift 0.9.1和maven-thrift-plugin 0.1.11,对于我service Voigy
中的每个方法(例如CandidateAnswer getAnswers(1:Query query) throws (1:VoigyException e)
),我看到类似
public void getAnswers(Query query, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
在Voigy.AsyncIface
而不是我期望的AsyncMethodCallback<CandidateAnswer>
。这是预期的结果,Thrift或maven-thrift-plugin中的已知错误,还是我的设置问题?
Voigy.thrift
:
namespace java com.voigy.api
struct Query {
1: required i32 scriptNodeId
2: required string text
}
struct Parameter {
1: required i32 paramTypeId
2: required i32 startIndex
3: required i32 endIndex
4: required string normalizedText
}
struct CandidateAnswer {
1: required i32 classifierId
2: required list<Parameter> parameters
}
exception VoigyException {
1: required string message
2: required i32 errorCode
}
service Voigy {
CandidateAnswer getAnswers(1:Query query) throws (1:VoigyException e)
void startLearning(1:i32 scriptNodeId, 2:bool force) throws (1:VoigyException e)
void startLearningParameters(1:bool force) throws (1:VoigyException e)
void startLearningAll(1:bool force) throws (1:VoigyException e)
}
我不知道如何查看maven-thrift-plugin使用的确切命令行,但是看一下代码,这应该是C:\thrift\thrift -r --gen java -out target/generated-sources/thrift **/*.thrift
(这会重现相同的结果)。