27

我正在使用 Leiningen(第一次)来管理我的写作应用程序。到目前为止,我已经定义了项目依赖项,在项目 lib 目录中安装了 deps,并定义了一个函数。当我lein repl从项目根目录运行然后调用我定义的函数时,我得到了错误unable to resolve symbol。任何人都知道我做错了什么以及如何通过 Leiningen 正确运行我的应用程序?谢谢。

4

2 回答 2

30

从 leiningen repl 你将不得不切换到你的函数用in-ns宏定义的命名空间。

(in-ns 'myproject.core)

那么该函数应该可用
,您也可以use从 repl 中的命名空间将其包含在默认(用户)命名空间中。

(use 'myproject.core)

之后,您可能需要考虑查看lein runlein uberjarlein jarleiningen 任务。

于 2011-07-21T21:45:58.133 回答
16

在我的项目中,对于包含这样定义的命名空间的 core.clj 文件:

(ns my-project.core)

...我在 project.clj:main中的 Leiningen 地图中设置了密钥:defproject

(defproject my-project "1.0.0-SNAPSHOT"
  :description "My project description"
  :dependencies [[org.clojure/clojure "1.2.1"]]
  :main my-project.core)

所以当我运行时lein repl,我的核心命名空间会自动加载,我会看到:

mac:my-project scott$ lein repl
REPL started; server listening on localhost:31515.
my-project.core=> 
于 2011-07-21T21:50:44.643 回答