【发布时间】:2009-11-04 16:02:44
【问题描述】:
我在使用 Enclojure REPL 并从中使用 clojure 模块时遇到问题。 Load/Change REPL to file/ns 适用于隔离的 clojure 文件,但会中断一个文件,该文件引用了我尝试从我的项目中使用的另一个 clojure 文件。
以下是具体步骤:
- 创建一个新项目。
- 创建一个 clojure 模块 foobar.clj(命名空间 com.acme.foobar)
-
在 foobar.clj 中定义一个返回值的函数:
(ns com.acme.foobar (:使用 com.acme.othermodule))
(defn myfunc1 [] “一”)
打开 Netbeans IDE REPL
-
从 foobar.clj 的上下文菜单中选择:
- 将 REPL 更改为 file/ns
- 加载
-
从 REPL 调用 (myfunc1) 函数。这工作得很好:
com.acme.foobar=> (myfunc1) “一个”
当我尝试从 foobar 引用其他文件时,问题就开始了。这是我的工作:
-
创建一个新的clojure模块othermodule.clj
(ns com.acme.othermodule)
(defn fromothermodule [] "b")
-
现在尝试从 foobar.clj 调用它:
(defn myfunc2 [] (来自其他模块))
-
我从 othermodule.clj 的上下文菜单中选择:
- 将 REPL 更改为 file/ns
- 加载
为了让 REPL 意识到它应该能够运行新模块。
- 我对现在引用 othermodule.clj 的 foobar.clj 做同样的事情,但我明白了:
CompilerException java.io.FileNotFoundException: 无法在类路径上找到 com/acme/othermodule__init.class 或 com/acme/othermodule.clj: (NO_SOURCE_FILE:50) com.acme.foobar=>
此错误消息来自“Change REPL to file/ns”和“Load”
我错过了什么?我应该做一些其他的技巧来实现这一点吗?即使是 Run->Clean and Build the main project 的绝望措施也无济于事(这当然会使 REPL 业务非常痛苦)。
我使用的是 NetBeans 6.7.1 和 enclojure-plugin-2009-11-3.nbm。
【问题讨论】: