簡體   English   中英

我如何讓Lein與JFreeChart和Dejcartes合作?

[英]How do I get Lein to work with JFreeChart and Dejcartes?

我正在嘗試了解如何在clojure中使用lein,並使其在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文件,對嗎?

    我在project.clj中放入了[org.jfree/chart "1.0.13"] ,但是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等搜索lein了。

  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"等。

非常感謝

麥可

第一步是找出您要獲取的庫的​​名稱。 如果它是Java庫,則可能在Maven Central上。 要找出答案,請轉到Maven Central搜索並搜索所需的任何庫。 在這種情況下,我去了那里搜索JFreeChart。 它給了我這個 您需要的罐子在此處列出。 它們分為三個相關部分:groupid,artifactid和verison。 groupid是斜杠(/)之前的部分,artifactid是斜杠之后的部分,版本是...嗯,版本。 放在一起,就可以得到[jfree/jfreechart "1.0.13"]

如果您要使用的庫是Clojure庫,則它可能位於clojars上 ,在這種情況下,您需要去那里進行搜索。

要回答未找到dejcartes的部分,這是因為它是一個古老的廢棄圖書館,不受leiningen,cake,maven或其他任何東西的管理。 它不在任何Maven存儲庫中。 除非您自己將它放在那里,否則您將無法在這里找到它,這完全是一個完全不同的問題。

為了回答您的第三個問題,leiningen有一個search任務,用於搜索各種存儲庫中的內容。 Cake目前在搜索Clojar時也有類似的事情,但是我可能會根據更通用的Leiningen代碼對其進行重寫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM