我在我的java代码库中使用finagle库。
下面是用scala代码编写的finagle的示例代码。
import com.twitter.finagle.transport.Transport
import com.twitter.finagle.{Http, Stack}
val client = Http.client
val params: Stack.Params = client.params
client.configured(client.params[Transport.Liveness].copy(keepAlive = Some(true)))我用java写了同样的东西如下-
import com.twitter.finagle.Http;
import com.twitter.finagle.transport.Transport;
public class FinagleClientDemo {
public static void main(String[] args) {
Http.Client client = Http.client()
.withLabel("myLabel");
client.withDecompression(true);
Transport.Liveness liveness = client.params().apply(Transport.Liveness.param());
}
}当我编译程序时,我会出错-
[error] /Users/myuser/Documents/chapter14/src/main/java/FinagleClientDemo.java:9:1: cannot find symbol
[error] symbol: method param()
[error] location: class com.twitter.finagle.transport.Transport.Liveness
[error] Transport.Liveness liveness = (Transport.Liveness)Http.client().params().apply(Transport.Liveness.param());
[error] (Compile / compileIncremental) javac returned non-zero exit code
[error] Total time: 4 s, completed Nov 6, 2018 1:10:43 PM
2. Waiting for source changes in project chapter14... (press enter to interrupt)我在这里犯了什么错。如何使我的程序编译?
发布于 2018-11-06 19:16:01
答案是
Transport.Liveness liveness = client.params().apply(Transport.Liveness$.MODULE$.param());https://stackoverflow.com/questions/53177906
复制相似问题