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

时间:2018-11-06 18:31:18

标签: scala scala-java-interop finagle twitter-finagle

我在Java代码库中使用了finagle scala库。

下面是finagle中用scala代码编写的示例代码。

    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());
        }
    }

我在Java中编写了以下内容-

    [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)

当我编译程序时,我得到以下错误-

{{1}}

我在这里犯了什么错误。如何使我的程序编译?

1 个答案:

答案 0 :(得分:0)

答案是

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