找不到符号符号:变量参数位置:class com.twitter.finagle.transport.Transport.Liveness

cannot find symbol symbol: variable param location: class com.twitter.finagle.transport.Transport.Liveness

我在 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)

我这里做错了什么。我怎样才能编译我的程序?

答案是

Transport.Liveness liveness = client.params().apply(Transport.Liveness$.MODULE$.param());