java - Maven项目如何调用Clojure函数
天蓬老师
天蓬老师 2017-04-18 09:06:02
0
1
350

我想在一个Java项目中使用clojure,可是不知道如何使用maven编译clj。
哪一位大神知道怎么弄,帮帮忙!

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(1)
迷茫

Interoperability issues between Java and clojure. Please refer to this document on the clojure official website.

The following materials and examples are from the above document.

Overall, operating Java from clojure is much easier and more convenient. If you want to use Clojure to implement a Java class, it will be a little more troublesome to let Java call it. There is a section in the above document that explains that the method is not pre-compiled:

Use clojure.java.api.Clojure to call clojure functions. For example:

IFn plus = Clojure.var("clojure.core", "+");
plus.invoke(1, 2);

My own experience is that this operation is enough. Generally, a pure static class in Java without instance methods is designed to encapsulate the above functions and provide type information.

Another method is to use aot, which is a bit more complicated. There is a Maven plugin that does this. I haven't used it myself.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template