Clojure 项目布局和相关导入
Clojure project layout and relative imports
我很难开始我的第一个 clojure 项目。我找到了大量的教程和问题的答案,但是 none 似乎回答了我的问题。
我使用 Leiningen 创建了一个空白项目。这个例子解释了我的问题:
project.clj:
(defproject clojurenet "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.6.0"]
[net.mikera/core.matrix "0.34.0"]
[org.clojure/math.numeric-tower "0.0.1"]]
:main ^:skip-aot clojurenet.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
src/clojurenet/core.clj:
(ns clojurenet.core)
(:require clojurenet.hello)
(:gen-class))
(defn -main
[& args]
(clojurenet.hello/helloworld)
src/clojurenet/hello.clj:
(ns clojurenet.hello)
(defn helloworld []
(println "Hello World!"))
当我 运行 lein run
时,我收到错误消息 Exception in thread "main" java.lang.ClassNotFoundException: clojurenet.hello, compiling:(clojurenet/core.clj:2:3)
。我该怎么做?
我也宁愿在核心文件中使用 :refer :all
语法,但我相信这个例子应该是最简单的。
我确定有一个愚蠢的简单解决方案,但我的研究没有成功。
此外,您是否有一些构建您的第一个项目的好教程?我发现有些教程已经过时了,而且大部分只描述了如何使用 REPL。
提前致谢!
我很难开始我的第一个 clojure 项目。我找到了大量的教程和问题的答案,但是 none 似乎回答了我的问题。
我使用 Leiningen 创建了一个空白项目。这个例子解释了我的问题:
project.clj:
(defproject clojurenet "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.6.0"]
[net.mikera/core.matrix "0.34.0"]
[org.clojure/math.numeric-tower "0.0.1"]]
:main ^:skip-aot clojurenet.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
src/clojurenet/core.clj:
(ns clojurenet.core)
(:require clojurenet.hello)
(:gen-class))
(defn -main
[& args]
(clojurenet.hello/helloworld)
src/clojurenet/hello.clj:
(ns clojurenet.hello)
(defn helloworld []
(println "Hello World!"))
当我 运行 lein run
时,我收到错误消息 Exception in thread "main" java.lang.ClassNotFoundException: clojurenet.hello, compiling:(clojurenet/core.clj:2:3)
。我该怎么做?
我也宁愿在核心文件中使用 :refer :all
语法,但我相信这个例子应该是最简单的。
我确定有一个愚蠢的简单解决方案,但我的研究没有成功。
此外,您是否有一些构建您的第一个项目的好教程?我发现有些教程已经过时了,而且大部分只描述了如何使用 REPL。
提前致谢!