【问题标题】:How do you import in Clojure nested Java classes that are in separate files?如何在 Clojure 中导入位于单独文件中的嵌套 Java 类?
【发布时间】:2012-06-23 13:39:21
【问题描述】:

例如 SearcherServer 和 SearcherClient 位于不同的文件中:

https://github.com/linkedin/indextank-engine/tree/master/src/main/java/com/flaptor/indextank/rpc

在 Java 中,SearcherClient 在其 main 方法中使用如下:

Searcher.Client client = new Searcher.Client(protocol);

https://github.com/linkedin/indextank-engine/blob/master/src/main/java/com/flaptor/indextank/rpc/SearcherClient.java#L106

【问题讨论】:

    标签: java clojure


    【解决方案1】:

    您可以将 Searcher.Client 称为com.flaptor.indextank.rpc.Searcher$Client

    客户端不在 Searcher 的单独文件中:它们都在自动生成的类 Searcher.java here 中。

    【讨论】:

    • 我收到Exception in thread "main" java.lang.IncompatibleClassChangeError: Implementing class 时:(import '(com.flaptor.indextank.rpc Searcher$Client))
    • 它应该可以工作:我刚刚下载了源代码;运行mvn clean install;添加 [com.flaptor.indextank/indextank-engine "1.0.0"] 作为 Leiningen 依赖项;启动 REPL 并运行 (import '(com.flaptor.indextank.rpc Searcher$Client)):它运行良好。您如何使用图书馆?
    • 现在可以使用了。我将 thrift 0.8.0 作为显式依赖项,将其删除即可解决问题。谢谢,安德鲁。
    猜你喜欢
    • 2020-11-10
    • 1970-01-01
    • 1970-01-01
    • 2018-06-23
    • 2012-03-11
    • 2023-02-14
    • 1970-01-01
    • 2019-07-03
    • 2020-05-25
    相关资源
    最近更新 更多