当 运行 lein repl 中的函数时,为什么我会得到 FileNotFoundException?

Why do I get a FileNotFoundExpection when running a function in lein repl?

使用这个 Clojure project.clj 我在 Windows cmd 中使用

启动了一个 REPL
lein figwheel

我运行下面的宏

(ns bota-web.views
    (:require [re-frame.core :as re-frame]
              [re-com.core :as re-com]))

结果为零。我预料到了这个结果。

然后我使用

在 Windows cmd 中启动了一个 REPL
lein repl

我运行同样的宏,看看下面发生了什么。

D:\Dropbox\DATA\MyClojureProjects\bota-web>lein repl
nREPL server started on port 59329 on host 127.0.0.1 - nrepl://127.0.0.1:59329
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
Java HotSpot(TM) Client VM 1.8.0_45-b15
Docs: (doc function-name-here)
      (find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e

user=> (ns bota-web.views
  #_=>     (:require [re-frame.core :as re-frame]
  #_=>               [re-com.core :as re-com]))

FileNotFoundException Could not locate re_frame/core__init.class or re_frame/core.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.  clojure.lang.RT.load (RT.java:456)
user=>

鉴于 project.clj 是否可以确定我这次收到 FileNotFoundException 的原因?

当您 运行 lein figwheel 启动 ClojureScript REPL 时,您可以 require CLJS 命名空间(例如 re-frame.core) .

当您使用 lein repl 时,您会启动一个 Clojure REPL,它仅适用于 Clojure 名称空间,因此会出现错误:Clojure 尝试查找名为 [=12= 的 Clojure 名称空间] 但它失败了。