1
我想使用clojure.java.jdbc來運行一些sql查詢。該REPL給我CompilerException了java.lang.RuntimeException:沒有這樣的命名空間:JDBCClojure的require函數中的別名不起作用
代碼和例外是
(require `[clojure.java.jdbc :as jdbc])
(def db-spec {:classname "com.mysql.jdbc.Driver" :subprotocol "mysql" :subname "//localhost:3306/foo" :user "root" :password "1234"})
(jdbc/query db-spec ["select * from client"])
=> nil
=> #'gaga.core/db-spec
CompilerException java.lang.RuntimeException: No such namespace: jdbc, compiling: (C:\Users\User\.IdeaIC14\system\tmp\form-init1177514063701175563.clj:3:1)
在我看來,在別名定義需要功能無法正常工作。如果我用全稱clojure.java.jdbc更換JDBC別名在上面的代碼中,一切似乎工作:
(require `[clojure.java.jdbc :as jdbc])
(def db-spec {:classname "com.mysql.jdbc.Driver" :subprotocol "mysql" :subname "//localhost:3306/foo" :user "root" :password "1234"})
(clojure.java.jdbc/query db-spec ["select * from client"])
=> nil
=> #'gaga.core/db-spec
=> ({:birthday #inst "1990-09-08T14:00:00.000-00:00", :gender 0, :addressid 1, :mobile "13890879283", :idnum "31090818790987", :idtype 0, :name "xiaomao", :version 0, :id 1})
我project.cli低於
(defproject gaga "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.6.0"] [org.clojure/java.jdbc "0.3.6"] [mysql/mysql-connector-java "5.1.35"]]
:main ^:skip-aot gaga.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
任何人都知道的原因是什麼?
一個變種永遠不會實際打印像 – noisesmith 2015-04-04 17:59:50