首页 文章

使用lein构建clojure项目时出错

提问于
浏览
4

我对clojure一点也不熟悉,而且我有一个我正在尝试构建的项目的源代码 . 该项目有一个project.clj文件,google说这意味着我应该使用lein构建工具 . 然而:

$ lein compile #lein jar does the same thing
Exception in thread "main" java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate testui/core__init.class oCompiling testui.core
r testui/core.clj on classpath

我怀疑project.clj可能会被破坏 . core.clj位于src / com / foodient / semanticanalysis / testui中,project.clj如下所示:

(defproject testui "1.0.0-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[org.clojure/clojure "1.3.0"]
                 [org.apache.poi/poi "3.8-beta4"]
                 [gate-clj "1.0.0"]]
  :aot [testui.core]
  :main testui.core
  :run-aliases {:test testui.core/-main})

有任何想法吗?

3 回答

  • 3

    如果你设置了一个lein项目,并且名称中包含了Clojuristic破折号,比如bene-csv(我的一个),那么lein new bene-csv会创建几个目录并且 ./bene-csv/project.clj . 我的core.clj位于 ./bene-csv/src/bene_csv/core.clj . 请注意,破折号在 bene_csv 中被删除,以支持下划线 .

    至于你的问题,很可能core.clj不在lein预期的位置,应该是 ./testui/src/testui/core.clj . 我希望这有帮助 .

  • 3

    我认为问题是core.clj不在正确的目录中 . 它应该在src / testui目录中 .

  • 4

    我的猜测是你应该改变你的代码的引用

    testui.core
    

    com.foodient.semanticanalysis.testui.core
    

    原因是最后一个点之前的命名空间部分对应于一个包名(该术语来自java和jvm)

    您表明您的来源是:

    src/com/foodient/semanticanalysis/testui
    

    所以包名是 com.foodient.semanticanalysis.testui

    您可能还应该更新clojure源文件中的命名空间声明以匹配此约定(或将源移动到 src/testui ) .

    希望能帮助到你 .

相关问题