我正在尝试运行一个使用ring,compojure,hiccup和lein-ring编写的clojure Web应用程序,当我运行lein ring服务器时,我得到了一个例外。
java.lang.IllegalArgumentException: No implementation of method: :as-file of protocol: #'clojure.java.io/Coercions found for class: clojure.l
ang.PersistentVector
at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:541)
at clojure.java.io$fn__8496$G__8491__8501.invoke(io.clj:35)
at clojure.java.io$file.invoke(io.clj:413)
at leiningen.core.project$absolutize.invoke(project.clj:308)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.AFn.applyTo(AFn.java:151)
at clojure.core$apply.invoke(core.clj:619)
at clojure.core$partial$fn__4190.doInvoke(core.clj:2396)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:619)
at clojure.core$update_in.doInvoke(core.clj:5587)
at clojure.lang.RestFn.invoke(RestFn.java:445)
at leiningen.core.project$absolutize_path.invoke(project.clj:314)
at clojure.core.protocols$fn__6034.invoke(protocols.clj:143)
at clojure.core.protocols$fn__6005$G__6000__6014.invoke(protocols.clj:19)
at clojure.core.protocols$seq_reduce.invoke(protocols.clj:31)
at clojure.core.protocols$fn__6028.invoke(protocols.clj:48)
at clojure.core.protocols$fn__5979$G__5974__5992.invoke(protocols.clj:13)
at clojure.core$reduce.invoke(core.clj:6177)
at leiningen.core.project$absolutize_paths.invoke(project.clj:322)
at leiningen.core.project$init_profiles.doInvoke(project.clj:603)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at leiningen.core.project$read.invoke(project.clj:684)
at leiningen.core.project$read.invoke(project.clj:685)
at leiningen.core.project$read.invoke(project.clj:686)
at leiningen.core.main$_main$fn__1332.invoke(main.clj:256)
at leiningen.core.main$_main.doInvoke(main.clj:252)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.lang.Var.invoke(Var.java:415)
at clojure.lang.AFn.applyToHelper(AFn.java:161)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.core$apply.invoke(core.clj:617)
at clojure.main$main_opt.invoke(main.clj:335)
at clojure.main$main.doInvoke(main.clj:440)
at clojure.lang.RestFn.invoke(RestFn.java:436)
at clojure.lang.Var.invoke(Var.java:423)
at clojure.lang.AFn.applyToHelper(AFn.java:167)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)
我已经完成的谷歌搜索显示了两个选项,测试套装没有正确命名,或者我的project.clj中有多个java源路径,我已经检查过了,所以我很难过。
有人可以筛选堆栈跟踪并指出我正确的方向吗?谢谢。
编辑:project.clj
(defproject cardmage "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:source-paths ["src/main/clojure"]
:java-source-paths ["src/main/java"] ; Java source is stored separately.
:test-path ["src/test/clojure"]
:resource-paths ["src/main/resource"]
:dependencies [[org.clojure/clojure "1.5.1"]
[ring "1.2.0"]
[compojure "1.1.5"]
[hiccup "1.0.4"]
[org.clojure/data.json "0.2.3"]
[org.clojure/data.xml "0.0.7"]
[org.clojure/java.jdbc "0.3.0-alpha4"]
[ring-anti-forgery "0.2.1"]
[lib-noir "0.6.8"]
[com.novemberain/monger "1.5.0"]
[mysql/mysql-connector-java "5.1.26"]
[com.amazonaws/aws-java-sdk "1.5.5"]
[ragtime "0.3.3"]]
:plugins [[ragtime/ragtime.lein "0.3.3"]
[lein-ring "0.8.7"]
[lein-beanstalk "0.2.7"]
[lein-cljsbuild "0.3.2"]]
:ragtime {:migrations ragtime.sql.files/migrations
:database "jdbc:mysql://localhost:3306/example_db?user=root"} ;; Fill this in later.
:ring {:handler cardmage.core/handler}
:aws {
:access-key ~(System/getenv "AWS_ACCESS_KEY")
:secret-key ~(System/getenv "AWS_SECRET_KEY")
:beanstalk {
:environments [{:name "beta"
:cname-prefix "beta"}
{:name "rc"
:cname-prefix "rc"}
{:name "prod"
:cname-prefix "www"}]}}
:cljsbuild {
:builds [{
:source-paths ["src/main/cljs"]
:compiler {
:output-to "resources/public/js/main.js" ; default: target/cljsbuild-main.js
:optimizations :advanced
:pretty-print true}}]})
我正在使用leiningen 2.3.2
答案 0 :(得分:3)
test-path
是单数,但你给了它一个向量。您只想给它一个字符串,或者按照lein's sample project.clj中的建议使用test-paths
(您也可以通过lein help sample
查看此文件)。