因此,我使用lein new app bot创建了一个新项目。然后,我在project.clj中添加了一个存储库和一个依赖项:

:dependencies [[org.clojure/clojure "1.8.0"]
               [net.dv8tion/JDA "2.2.0_334"]]
:repositories [["jcenter" {:url "http://jcenter.bintray.com"}]]


那行得通。但是我无法将其导入clojure文件中,这些都不起作用(我尝试在类名(import 'net.dv8tion.jda)和小写字母jda之前添加单引号!):

; 1
(ns bot.core
  (:gen-class) (:import net.dv8tion.JDA))
; 2
(ns bot.core
  (:gen-class))
(import net.dv8tion.JDA)


整个错误:

PS C:\Users\glxw\Desktop\clojure\bot> lein run
Exception in thread "main" java.lang.ClassNotFoundException: net.dv8tion.JDA, compiling:(bot/core.clj:1:1)
        at clojure.lang.Compiler.load(Compiler.java:7391)
        at clojure.lang.RT.loadResourceScript(RT.java:372)
        at clojure.lang.RT.loadResourceScript(RT.java:363)
        at clojure.lang.RT.load(RT.java:453)
        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$load_one.invoke(core.clj:5692)
        at clojure.core$load_lib$fn__5626.invoke(core.clj:5737)
        at clojure.core$load_lib.invokeStatic(core.clj:5736)
        at clojure.core$load_lib.doInvoke(core.clj:5717)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:648)
        at clojure.core$load_libs.invokeStatic(core.clj:5774)
        at clojure.core$load_libs.doInvoke(core.clj:5758)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:648)
        at clojure.core$require.invokeStatic(core.clj:5796)
        at clojure.core$require.doInvoke(core.clj:5796)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at user$eval5$fn__7.invoke(form-init5148051899064938422.clj:1)
        at user$eval5.invokeStatic(form-init5148051899064938422.clj:1)
        at user$eval5.invoke(form-init5148051899064938422.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:6927)
        at clojure.lang.Compiler.eval(Compiler.java:6917)
        at clojure.lang.Compiler.load(Compiler.java:7379)
        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.lang.ClassNotFoundException: net.dv8tion.JDA
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:69)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at clojure.lang.DynamicClassLoader.loadClass(DynamicClassLoader.java:77)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)
        at clojure.lang.RT.classForName(RT.java:2168)
        at clojure.lang.RT.classForNameNonLoading(RT.java:2181)
        at bot.core$eval20$loading__5569__auto____21.invoke(core.clj:1)
        at bot.core$eval20.invokeStatic(core.clj:1)
        at bot.core$eval20.invoke(core.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:6927)
        at clojure.lang.Compiler.eval(Compiler.java:6916)
        at clojure.lang.Compiler.load(Compiler.java:7379)
        ... 42 more


我听说过有关java-source-paths的信息,但如何找到应该放置的路径?

最佳答案

I can't find那里有这样的课程。我相信您的意思是net.dv8tion.jda.JDA

07-24 09:32