【问题标题】:How do I get Lein to work with JFreeChart and Dejcartes?如何让 Lein 使用 JFreeChart 和 Dejcartes?
【发布时间】:2011-10-23 04:26:59
【问题描述】:

我正在尝试了解如何将 lein 与 clojure 一起使用,并让它在 Win7 x64 上下载正确的 .jar 文件。作为一个具体的例子,我正在尝试使用 JFreeChart 和 Dejcartes。

我的问题是通用的,并不特定于 JfreeChart。我基本上不明白如何缩小看到使用某些特定包的示例与通过 lein 为我提供该包之间的差距。希望有人能以同样适用于其他包的方式回答。

参考此链接:https://github.com/markmfredrickson/dejcartes/blob/master/Readme.txt 我的 project.clj 是这样的(注释掉这篇文章的最后两行)。

(defproject monty "1.0.0-SNAPSHOT"
  :description "Monty Game Challenge"
  :dependencies [[org.clojure/clojure "1.2.1"]
                 [org.clojure/clojure-contrib "1.2.0"]
                ;[org.jfree/chart "1.0.13"]])
                 [com.markmfredrickson/dejcartes "1.0.0"]])
  1. 我看到在 Dejcartes readme.txt 中使用了(import '(org.jfree.chart chartframe)),所以我认为这意味着我需要 JFreeChart 的 .jar 文件,对吧?

    我将[org.jfree/chart "1.0.13"] 放在我的project.clj 中,但lein deps 抱怨如下:

    C:\Users\me\code\Clojure\monty>lein deps
    Downloading: org/jfree/chart/1.0.13/chart-1.0.13.pom from central
    Downloading: org/jfree/chart/1.0.13/chart-1.0.13.pom from clojure
    Downloading: org/jfree/chart/1.0.13/chart-1.0.13.pom from clojars
    Downloading: org/jfree/chart/1.0.13/chart-1.0.13.pom from central
    Downloading: org/jfree/chart/1.0.13/chart-1.0.13.jar from central
    Downloading: org/jfree/chart/1.0.13/chart-1.0.13.jar from clojure
    Downloading: org/jfree/chart/1.0.13/chart-1.0.13.jar from clojars
    Downloading: org/jfree/chart/1.0.13/chart-1.0.13.jar from central
    An error has occurred while processing the Maven artifact tasks.
    Diagnosis:
    Unable to resolve artifact: Missing:
    ----------
    1) org.jfree:chart:jar:1.0.13
    Try downloading the file manually from the project website.
    

    我想我需要直接下载 .jar 文件,但是一旦我有了 .jar 文件,我该如何哄 lein 为我把它放在类路径中,这样我就可以使用 emacs 等来处理它?

  2. Dejcartes 示例使用 (require '[com.markmfredrickson.dejcartes :as chart]),因此我将 [com.markmfredrickson/dejcartes "1.0.0"] 放入我的 project.clj 中。当我运行 lein deps 时,这似乎开始下载一些东西,但随后它以同样的方式阻塞:

    C:\Users\me\code\Clojure\monty>lein deps
    Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.pom from central
    Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.pom from clojure
    Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.pom from clojars
    Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.pom from central
    Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.jar from central
    Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.jar from clojure
    Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.jar from clojars
    Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.jar from central
    An error has occurred while processing the Maven artifact tasks.
     Diagnosis:
    
    Unable to resolve artifact: Missing:
    ----------
    1) com.markmfredrickson:dejcartes:jar:1.0.0
    
    Try downloading the file manually from the project website.        
    

    据称从 (clojars) 下载的其中一个存储库甚至没有在大列表中显示 Dejcartes。如何让 Lein 下载 Dejcartes?

  3. 最后,鉴于我想开始使用一些包,我如何让 lein 自动查找最新版本?我还没有看到任何关于此的内容,所有 project.clj 示例似乎都对版本进行了硬编码,例如 "1.0.2" 等。

非常感谢

迈克尔

【问题讨论】:

  • Leiningan 有时会因大量下载而窒息,我发现。我的处理方式如下: - 编辑 project.clj 以包含依赖项(正如您已经完成的那样)。 - 运行 lein 部门。 - 检查它是否停止(即,如果特定依赖项占用了几分钟) - 如果停止,则杀死 lein deps。 - 重新开始。如果我这样做几次,通常我可以让 lein deps 完成所有依赖项。
  • ALSO:您能否重命名此问题,以便在标题中明确您要问的内容(例如:为什么 Leiningan 在尝试获取 Dejcartes 和 JFree 项目时会失败?)
  • 我澄清了这个问题。 Lein 并没有因为下载量太大而窒息;窒息是因为我放错了。

标签: clojure dependencies jfreechart leiningen


【解决方案1】:

第一步是找出你想要获取的库的​​名称。如果它是一个 Java 库,它可能在 Maven Central 上。要找出答案,请转到 Maven Central Search 并搜索您想要的任何库。在这种情况下,我去那里搜索 JFreeChart。它给了我this。你想要的罐子列在那里。它们分为三个相关部分:groupid、artifactid 和 verison。 groupid 是斜线 (/) 之前的部分,artifactid 是斜线之后的部分,版本是......好吧,版本。把这些放在一起,你就有了[jfree/jfreechart "1.0.13"]

如果您要查找的库是 Clojure 库,它可能位于 clojars,在这种情况下,您会想去那里搜索。

要回答关于未找到 dejcartes 的部分,那是因为它是一个古老且废弃的库,不受 leiningen、cake、maven 或其他任何东西的管理。它不在任何 Maven 存储库中。除非你自己把它放在那里,否则你将无法在那里找到它,这完全是一个完全不同的问题。

为了回答您的第三个问题,leiningen 有一个 search 任务,用于搜索各种 repos 中的东西。 Cake 目前有一个类似的搜索 clojars 的东西,但我可能会根据更通用的 Leiningen 代码重写它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-25
    • 2011-08-13
    • 2015-01-29
    • 1970-01-01
    • 2014-11-28
    • 1970-01-01
    • 2017-02-13
    • 2018-07-24
    相关资源
    最近更新 更多