(使用'korma.db)指令有什么问题?

时间:2014-03-05 19:26:48

标签: clojure leiningen korma

当我尝试使用以下非常简单的Clojure测试文件创建使用lein的uberjar时,我收到错误

Compiling korma-test.core
Exception in thread "main" java.lang.Exception: 
lib names inside prefix lists must not contain periods, compiling:(core.clj:1:1)

并无法弄清楚原因。我从sqlkorma.com的文档部分获得了(use 'korma.db),并尝试了一个require语句(此处未在我的示例中列出)。

project.clj

(defproject korma-test "0.1.0-SNAPSHOT"
  :description "korma db test"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [korma "0.3.0-RC5"]]
   :main korma-test.core)

core.clj(简化)

(ns korma-test.core
  (:gen-class)
  (use 'korma.db)
  (require '[clojure.string :as str])
  (:import java.util.Date)
)

(defn -main 
  [& args]
  (let [opts (parse-opts args)
        start-time (str (Date.))]))

1 个答案:

答案 0 :(得分:5)

ns宏使用关键字代替函数,并使用引用的参数。

(ns korma-test.core
  ...
  (:use korma.db)
  (:require [clojure.string :as str])
  ...)

这里有一篇很好的文章:http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html