我在引用通过:gen-class
.
我可以展示的最小示例是:
(defproject test-proj
:dependencies [[org.clojure/clojure "1.8.0"]]
:aot [test-proj.test])
(ns test-proj.test
(:gen-class))
(defn -main []
(println test_proj.test)) ; Error here
问题是,这会ClassNotFoundException
在标记线上产生一个。
(我尝试了上述文件-
和.围绕那个,我需要下划线来引用。)_
project.clj
-main
test_proj.test
如果我进入项目根文件,没有target
文件夹,所以它不会生成类。如果我进入终端并运行lein compile
,它会在 下生成所需的类target
,并且上面的代码运行没有错误。这是一个糟糕的解决方法。如果我修改文件并忘记手动重新编译它怎么办?在我每次执行clean
.
作为在黑暗中的镜头,我尝试在宏compile
下方使用:ns
(compile 'test-proj.test)
如果我使用破折号,compile
似乎什么都不做。我可能会误解它的用法,但它不会在target
. 如果我使用下划线,它会给出一个异常,指出找不到命名空间。
有没有办法让类自动生成,所以我不需要lein compile
每次都运行?我认为这就是:aot
in theproject.clj
所做的。