2017-05-17 34 views
2

我已經得到了leiningen找到一個圖書館,我在一個企業Artifactory存儲庫,它似乎下載它就好了,但是當我打開試着require它,運行與代碼lein run帶回FileNotFoundException爲什麼我不需要Clojure文件中的Java庫?

我的項目文件看起來像這樣:

(defproject clj-test "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"] 
      [com.ourgroup/library "1.0.0"]] 
    :repositories [["releases" {:url "https://url-to-our-repo" 
          :username "username" 
          :password "password"}]] 
    :main ^:skip-aot clj-test.core 
    :target-path "target/%s" 
    :profiles {:uberjar {:aot :all}}) 

我的單碼文件看起來像這樣:

(ns clj-test.core 
    (:gen-class) 
    (:require [library :as lib])) 

(defn -main 
    "I don't do a whole lot ... yet." 
    [& args] 
    (println "And now for something completely different...")) 

回答

2

您需要import類。要獲取該類的名稱,請查看jar(或Java源代碼)並查找構成需要導入的完全限定類名的Java包和類。

我編輯了這個。我之前的錯誤已經通過評論得到糾正:「你需要命名空間;你導入類,需要一個類是不好的」。因此,對於Java interop,您需要導入類,就像您在編寫Java源文件時所做的一樣。

+0

這是一個名爲「library」的包的JAR,以及該包中的幾個類。非常平坦。 –

+0

您需要命名空間;你導入類。要求上課不是好事。 – amalloy

+0

啊哈!這就是我所錯過的。非常感謝。 –

相關問題