Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何编译不在";下的clojure模块;src";在莱因项目中_Clojure_Leiningen - Fatal编程技术网

如何编译不在";下的clojure模块;src";在莱因项目中

如何编译不在";下的clojure模块;src";在莱因项目中,clojure,leiningen,Clojure,Leiningen,我使用lein new app hello构建了我的项目,所以我有这个结构 . └── src └── hello └── core.clj └── project.clj └── test └── .. 我想向我的项目中添加另一个helper模块,这样我就可以在测试和src模块中使用代码,因为我希望它与src目录解耦 所以我添加了一个助手模块 . └── src └── hello └── core.clj └── project.clj └─

我使用lein new app hello构建了我的项目,所以我有这个结构

.
└── src
    └── hello
        └── core.clj
└── project.clj
└── test
└── ..
我想向我的项目中添加另一个helper模块,这样我就可以在测试和src模块中使用代码,因为我希望它与src目录解耦

所以我添加了一个助手模块

.
└── src
    └── hello
        └── core.clj
└── project.clj
└── test
└── helpers
    └──hello
         └── helpers.clj
如何更改project.clj文件以使
lein运行
compile
leinrun
不编译,当我试图要求helpers名称空间时抛出以下错误

线程“main”java.lang.ClassNotFoundException中的异常: hello.helpers,编译:(hello/core.clj:7:3)

我的project.clj文件与默认文件类似:

(defproject hello "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.8.0"]]
  :main ^:skip-aot hello.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})
但是在IDE(IntelliJ)中,它在REPL中工作正常,不会引发类not found exception。

Add

:source-paths ["src" "helpers"]
添加到您的
project.clj
文件。

添加

:source-paths ["src" "helpers"]
到您的
project.clj
文件。

使用
(:require[hello.helpers:as h])
是正确的请求方式。我只是使用
(hello.helpers/test)
进行测试,但这不起作用使用
(:require[hello.helpers:as h])
是正确的请求方式。我只是在使用
(hello.helpers/test)
进行测试,但这不起作用