我在我的 java 代码库中使用了 finagle scala 库。
下面是用 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)
我在这里犯了什么错误。如何使我的程序编译?