在 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
.您的代码基本上对类进行静态调用。您需要 new
从你的例子。
(-> (HttpClientConfig$Builder. "http://localhost:9200") ; note the `.`
(.build))
关于java - Clojure 访问需要 var 的静态内部类构建器,但在构建时映射到类错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57131549/