我在同一个目录中有两个文件test.clj和test2.clj。
我想从test2.clj导入函数
test.clj看起来像这样:
(ns test
(:require [test2 :refer :all])
)test2.clj如下所示:
(defn showworld []
(println "hello world")
)但当我在苹果酒中执行test.clj时,我得到:无法在类路径上找到test2__init.class、test2.clj或test2.cljc。
发布于 2021-07-11 09:40:57
您缺少test2.clj中的命名空间声明。当我们:require某些东西时,我们需要的是名称空间(而不是文件)。
尝试将test2.clj更改为以下内容:
(ns test2)
(defn showworld []
(println "hello world"))发布于 2021-07-11 21:55:27
尽管您提供的文件名为test2.clj,但这还不够,您还需要使用ns进行名称空间声明,然后test2.clj中的代码如下所示:
(ns test2)
(defn showworld []
(println "hello world")
)https://stackoverflow.com/questions/68332549
复制相似问题