Clojure 访问静态内部 class 构建器期望 var 但在构建时映射到 class 错误

Clojure accessing static inner class builder expecting var but mapped to class error on build

在 Clojure 中我想互操作使用:

JestClientFactory factory = new JestClientFactory();
factory.setHttpClientConfig(new HttpClientConfig
                    .Builder("http://localhost:9200")
                    .build());

所以我写了一些这样的代码:

 (:import (io.searchbox.client JestClientFactory)
          (io.searchbox.client.config HttpClientConfig$Builder))

 (let [factory (JestClientFactory.)
       http-client-config (-> (HttpClientConfig$Builder "http://localhost:9200")
                           (.build))])

但是我在构建 jar 时遇到以下错误

Expecting var, but HttpClientConfig$Builder is mapped to class io.searchbox.client.config.HttpClientConfig$Builder

任何帮助都会很棒。

你缺少HttpClientConfig$Builder后面的.。您的代码基本上对 class 进行静态调用。您需要示例中的 new

(-> (HttpClientConfig$Builder. "http://localhost:9200") ; note the `.`
    (.build))