gpt4 book ai didi

java - lein 编译问题 (Clojure)

转载 作者:行者123 更新时间:2023-11-30 06:06:16 24 4
gpt4 key购买 nike

我已经尝试寻找解决方案 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 header :

(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

所以我不知道问题出在哪里。请帮忙=)

最佳答案

my-functions.core 应该是命名空间定义中的 funcs.core 。所以而不是:

(ns my-functions.core ...)

有:

(ns funcs.core ...)

问题是命名空间的名称和文件所在目录的名称似乎不一致。另一种解决方案是将目录名称从 funcs 更改为 my-functions

关于java - lein 编译问题 (Clojure),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44510311/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com