Clojure:无法在 Cider 的类路径中找到 test2__init.class、test2.clj 或 test2.cljc

Clojure: Could not locate test2__init.class, test2.clj or test2.cljc on classpath in Cider

我在同一目录中有两个文件 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。

您缺少 test2.clj 中的名称空间声明。当我们 :require 某些东西时,我们需要命名空间(而不是文件)。

尝试将 test2.clj 更改为以下内容:

(ns test2)

(defn showworld []
    (println "hello world"))

虽然您提供的文件名为 test2.clj,但这还不够,您还应该有我们用 ns 做的名称空间声明,然后 test2.clj 中的代码如下以下 :

(ns test2)

(defn showworld []
    (println "hello world")
)