问题描述
我试图在Linux上从成功的构建环境在Windows 7上设置一个lein构建环境。我有maven和jdk与lein一起安装。
I am trying to set up a lein build environment on Windows 7 haven copied files from a successful build environment on Linux. I have maven and the jdk installed along with lein.
HOME指向maven目录所在的 c:\Users \cnorton
。
HOME points to c:\Users\cnorton
where the maven directories are located.
当试图运行lein repl或lein编译时,我得到这个错误,无法弄清楚我做错了什么。
I get this error when trying to run lein repl or lein compile, and cannot figure out what I am doing wrong.
Caused by:java.lang.Exception:加载'/ repl_test / core'后找不到命名空间'repl-test.core'
Caused by: java.lang.Exception: namespace 'repl-test.core' not found after loading '/repl_test/core'
这里是project.clj
Here is project.clj
(defproject repl-test "0.0.1-SNAPSHOT"
:description "TODO: add summary of your project"
:dependencies [[org.clojure/clojure "1.4.0"]
[org.clojure/clojure-contrib "1.2.0"]
[clojure-csv/clojure-csv "1.2.4"]
[org.clojure/tools.cli "0.1.0"]
[clj-http "0.1.3"]]
:aot [repl-test.core]
:main repl-test.core)
这是src / repl_test / core.clj
Here is the first part of src/repl_test/core.clj
(ns repl-test.core
(:gen-class)
(:use clojure.contrib.command-line)
(:require [clojure.contrib.string :as cstr])
(:require [clojure.contrib.trace :as ctr])
(:require [clojure.string :as sstr])
(:use clojure-csv.core))
$ b b
如果有人可以发布一个project.clj和一个core.clj的头部,允许项目是一个主要的。如果有人可以超级有用。
I would be super helpful if someone could post as an answer a project.clj and the header of a core.clj that allows the project to be a main.
推荐答案
我会避免在你的文件夹名称和命名空间中的 - ,它实际上是转换为_,但不是在所有地方。
I would avoid "-" in your folder names and namespaces, it is actually converted to "_" but not in all places.
以下内容可能适用于您,也可能不适用。我有你的骨骼项目使用:
The following may or may not work for you. I got your skeleton project working with:
(defproject st1 "1.0.0-SNAPSHOT"
:description "TODO: add summary of your project"
:dependencies [[org.clojure/clojure "1.4.0"]
[org.clojure/clojure-contrib "1.2.0"]
[clojure-csv/clojure-csv "1.2.4"]
[org.clojure/tools.cli "0.1.0"]
[clj-http "0.1.3"]]
:aot [repl_test.core]
:main repl_test.core)
您有:
(ns repl_test.core
(:gen-class)
(:use clojure.contrib.command-line)
(:require [clojure.contrib.string :as cstr])
(:require [clojure.contrib.trace :as ctr])
(:require [clojure.string :as sstr])
(:use clojure-csv.core))
我已将文件夹 repl-test 重命名为 repl_test ,并使用下划线。
And I renamed the folder repl-test to repl_test with underscore.
b
$ b
Then
lein compile
和
lein run
b $ b
通过好奇心,我还查看了,他们是使用 - 无处不在,除了文件夹名称,所以可能有幸运复制他们做了什么。
By curiosity, I also looked at clojure-csv, and they are using "-" everywhere, except in the folder name, so may have luck copying what they did.
此外,引用部分:
Clojure尊重目录和文件的Java命名约定,但命名空间名称的Lisp命名约定。因此,Clojure命名空间com.my-app.utils将位于名为com / my_app / utils.clj的路径中。特别注意下划线/连字符的区别。
And from the Clojure Programming Wiki section on java packages:"Clojure respects Java naming conventions for directories and files, but Lisp naming conventions for namespace names. So a Clojure namespace com.my-app.utils would live in a path named com/my_app/utils.clj. Note especially the underscore/hyphen distinction."
这篇关于为什么Java抱怨没有找到命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!