我一直试图找到一个解决方案3个小时,没有任何帮助。 有一个lein项目有 project.clj :
(defproject funcs "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"]
[org.xerial/sqlite-jdbc "3.7.2"]])
同样,还有一个标题为 core.clj :
(ns funcs.core
(:gen-class)
(:import (java.sql.Connection)
(java.sql.DriverManager)
(java.sql.ResultSet)
(java.sql.SQLException)
(java.sql.Statement))
(:require [clojure.string :as str]
[clojure.java.jdbc :as j])) ; JDBC Driver for SQLite
在lein deps
之后我尝试编译 core.clj ,但得到:
Compiling src/funcs/core.clj
Could not locate funcs/core/clj__init.class or funcs/core/clj.clj on classpath.
Exception in thread "main" java.io.FileNotFoundException: Could not locate funcs/core/clj__init.class or funcs/core/clj.clj on classpath., compiling:(/tmp/form-init8916675856325046616.clj:1:73)
at clojure.lang.Compiler.load(Compiler.java:7391)
at clojure.lang.Compiler.loadFile(Compiler.java:7317)
at clojure.main$load_script.invokeStatic(main.clj:275)
at clojure.main$init_opt.invokeStatic(main.clj:277)
at clojure.main$init_opt.invoke(main.clj:277)
at clojure.main$initialize.invokeStatic(main.clj:308)
at clojure.main$null_opt.invokeStatic(main.clj:342)
at clojure.main$null_opt.invoke(main.clj:339)
at clojure.main$main.invokeStatic(main.clj:421)
at clojure.main$main.doInvoke(main.clj:384)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:383)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
Caused by: java.io.FileNotFoundException: Could not locate funcs/core/clj__init.class or funcs/core/clj.clj on classpath.
at clojure.lang.RT.load(RT.java:456)
at clojure.lang.RT.load(RT.java:419)
at clojure.core$load$fn__5677.invoke(core.clj:5893)
at clojure.core$load.invokeStatic(core.clj:5892)
at clojure.core$load.doInvoke(core.clj:5876)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5697)
at clojure.core$compile$fn__5682.invoke(core.clj:5903)
at clojure.core$compile.invokeStatic(core.clj:5903)
at clojure.core$compile.invoke(core.clj:5895)
at user$eval20$fn__29.invoke(form-init8916675856325046616.clj:1)
at user$eval20.invokeStatic(form-init8916675856325046616.clj:1)
at user$eval20.invoke(form-init8916675856325046616.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6927)
at clojure.lang.Compiler.eval(Compiler.java:6917)
at clojure.lang.Compiler.eval(Compiler.java:6917)
at clojure.lang.Compiler.load(Compiler.java:7379)
... 14 more
Compilation failed: Subprocess failed
命令ls -R
输出:
.:
CHANGELOG.md LICENSE README.md src test
doc project.clj resources target
./doc:
intro.md
./resources:
./src:
funcs
./src/funcs:
core.clj
./target:
classes native stale
./target/classes:
META-INF
./target/classes/META-INF:
maven
./target/classes/META-INF/maven:
funcs
./target/classes/META-INF/maven/funcs:
funcs
./target/classes/META-INF/maven/funcs/funcs:
pom.properties
./target/native:
Linux Mac Windows
./target/native/Linux:
amd64 i386
./target/native/Linux/amd64:
libsqlitejdbc.so
./target/native/Linux/i386:
libsqlitejdbc.so
./target/native/Mac:
i386 x86_64
./target/native/Mac/i386:
libsqlitejdbc.jnilib
./target/native/Mac/x86_64:
libsqlitejdbc.jnilib
./target/native/Windows:
amd64 x86
./target/native/Windows/amd64:
sqlitejdbc.dll
./target/native/Windows/x86:
sqlitejdbc.dll
./target/stale:
leiningen.core.classpath.extract-native-dependencies
./test:
funcs
./test/funcs:
core_test.clj
所以我不知道问题出在哪里。帮助plz =)
答案 0 :(得分:5)
my-functions.core
应为funcs.core
。所以而不是:
(ns my-functions.core ...)
有:
(ns funcs.core ...)
问题是,似乎命名空间的名称和文件所在目录的名称是不一致的。另一种解决方案是将目录名称从funcs
更改为my-functions
。