【问题标题】:Cannot understand defproject? [closed]看不懂defproject? [关闭]
【发布时间】:2017-01-01 08:31:32
【问题描述】:

新的 linux (centos7)、新的 lighttable、新的 lein、新的项目:

clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: defproject in this context, 正在编译:(/home/zzz/nnn/lighttable/project.clj:1:1)

这是项目:

(defproject lighttable "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"]])

在尝试 clojure 几年后,有一个项目正在生产中。 (当然不是这个):我错过了什么吗?

【问题讨论】:

  • 您是在尝试以任何方式运行您的 project.clj,还是将其作为源代码的一部分?该文件不应该直接运行(基本上),但lein 将其作为描述做什么。
  • 突然间,它毫无理由地运行了。

标签: clojure leiningen


【解决方案1】:

你能从一个干净的目录再试一次吗?它似乎对我有用:

~/tmp9 > lein new app lighttable
Generating a project called lighttable based on the 'app' template.
~/tmp9 > cd lighttable 
~/tmp9/lighttable > lein run
Hello, World!
~/tmp9/lighttable > cat project.clj 
(defproject lighttable "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"]]
  :main ^:skip-aot lighttable.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

我注意到您有两个 :url 条目并且缺少一些其他内容。你是用lein new app lighttable命令创建的吗?

【讨论】:

    【解决方案2】:

    如果您像我一样使用 IntelliJ + Cursive,那么如果您的运行/调试配置指向 project.clj 文件而不是 core.clj 用于 Clojure 应用程序配置且 How to run it 设置为 @987654324,则会发生这种情况@

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-21
      • 2015-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-10
      相关资源
      最近更新 更多