【问题标题】:Error building clojure project with lein使用 lein 构建 clojure 项目时出错
【发布时间】:2012-05-27 05:53:18
【问题描述】:

我对 clojure 一点也不熟悉,而且我有一个我正在尝试构建的项目的源代码。该项目有一个 project.clj 文件,谷歌说这意味着我应该使用 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})

有什么想法吗?

【问题讨论】:

    标签: clojure leiningen


    【解决方案1】:

    如果您设置了一个 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。我希望这会有所帮助。

    【讨论】:

    • 谢谢,成功了。我现在对另一个文件也有同样的错误,但我想我可以用同样的方法修复它。
    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      我的猜测是您应该更改对代码的引用

      testui.core
      

      com.foodient.semanticanalysis.testui.core
      

      原因是命名空间中最后一个点之前的部分对应一个包名(这个词来源于java和jvm)

      您表示您的来源在:

      src/com/foodient/semanticanalysis/testui
      

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

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

      希望对你有帮助。

      【讨论】:

        猜你喜欢
        • 2020-03-18
        • 2017-07-20
        • 1970-01-01
        • 1970-01-01
        • 2018-09-22
        • 2020-10-16
        • 2021-04-07
        • 2011-11-04
        相关资源
        最近更新 更多