我正在试验一个简单的 Thrift 服务器,并想用 java 编写客户端。我运行了命令
->节俭-gen java BLT.thrift
生成的 java 文件 Optimization.java 在 Eclipse IDE 中显示以下错误。
public static class Client extends org.apache.thrift.TServiceClient implements Iface
错误:类型 TServiceClient 不能是 Client 的超类;超类必须是类
public Client(org.apache.thrift.protocol.TProtocol prot)
{
super(prot, prot);
}
构造函数 Object(TProtocol, TProtocol) 未定义。......
我仍然继续编译它。
->mvn clean install
Optimization.java:[38,54] no interface expected here
[ERROR] /thrift/Optimization.java:[39,83] type parameter model.thrift.Optimization.Client is not within its bound
[ERROR] /thrift/Optimization.java:[68,6] cannot find symbol
symbol : method
sendBase(java.lang.String,com.model.thrift.Optimization.maximizeRevenue_args)
location: class model.thrift.Optimization.Client
[ERROR] /thrift/Optimization.java:[74,6] cannot find symbol
symbol : method
receiveBase(model.thrift.Optimization.maximizeRevenue_result,java.lang.String)
location: class model.thrift.Optimization.Client
[ERROR] /thrift/Optimization.java:[98,97] cannot find symbol
symbol : variable ___protocolFactory
location: model.thrift.Optimization.AsyncClient
[ERROR] /thrift/Optimization.java:[98,117] cannot find symbol
symbol : variable ___transport
location: class model.thrift.Optimization.AsyncClient
[ERROR] /thrift/Optimization.java:[99,10] cannot find symbol
symbol : variable ___currentMethod
location: class model.thrift.Optimization.AsyncClient
[ERROR] /thrift/Optimization.java:[100,6] cannot find symbol
symbol : variable ___manager
location: class thrift.Optimization.AsyncClient
[ERROR] /thrift/Optimization.java:[387,23] cannot find symbol
symbol : method getScheme()
location: class org.apache.thrift.protocol.TProtocol
[ERROR] /thrift/Optimization.java:[391,23] cannot find symbol
symbol : method getScheme()
location: class org.apache.thrift.protocol.TProtocol
[ERROR] /thrift/Optimization.java:[665,23] cannot find symbol
symbol : method getScheme()
location: class org.apache.thrift.protocol.TProtocol
[ERROR] /thrift/Optimization.java:[669,23] cannot find symbol
symbol : method getScheme()
-> mvn dependency:tree | grep -i thrift
[INFO] \- org.apache.thrift:libthrift:jar:0.8.0:compile
-> thrift -version java
Thrift version 0.8.0
我确实找到了这个线程,但推荐的解决方案对我不起作用 Maven Thrift 存储库
我还对用于生成代码的 jar 和使用上面的 pom 提取的 jar 进行了校验和。有谁知道为什么这些会有所不同
->md5sum /usr/local/lib/libthrift-0.8.0.jar
fff7102558cb0ab1c103b62752166ce8 /usr/local/lib/libthrift-0.8.0.jar
->md5sum ~/.m2/repository/org/apache/thrift/libthrift/0.8.0/libthrift-0.8.0.jar
d68695bb2406cb2ab5fbae6ff6e27d7e
/home/nipun/.m2/repository/org/apache/thrift/libthrift/0.8.0/libthrift-0.8.0.jar
任何帮助/见解将不胜感激。