Midje Project.clj给出了错误

时间:2015-01-19 07:41:44

标签: clojure midje

我在我的环网服务器上看到了一个错误,我开始使用它 lein with-profile dev ring server

java.io.FileNotFoundException: Could not locate midje/sweet__init.class or midje/sweet.clj on classpath: , compiling:(news/routes/headlines_test.clj:1:1)
...

这是我的project.clj:

(defproject news "0.1.0-SNAPSHOT"
  :description "..."
  :url "https://herokuapp.com"
  :min-lein-version "2.0.0"

  :ring {:handler news.core.handler/app
         :init    news.core.handler/init}

  :dependencies [[org.clojure/clojure   "1.6.0"]
                 [compojure             "1.3.1"]
                 [ring/ring-defaults    "0.1.3"]
                 [liberator             "0.11.0"]
                 [cheshire              "5.3.1"]
                 [org.clojure/java.jdbc "0.3.6"]
                 [postgresql/postgresql "9.3-1102.jdbc41"]
                 [yesql                 "0.5.0-rc1"]
                 [environ               "1.0.0"]]

  :plugins [[lein-ring    "0.9.1"]
            [lein-environ "1.0.0"]]

  :profiles {:dev-default  {:dependencies [[ring/ring-devel           "1.3.1"]]}
             :test-default {:dependencies [[midje                     "1.6.3"]
                                          [javax.servlet/servlet-api  "2.5"]
                                          [ring-mock                  "0.1.5"]]
                            :plugins      [[lein-midje                "3.1.3"]]}
             :production-default {:ring {:open-browser? false
                                         :stacktraces?  false
                                         :auto-reload?  false}}

             ;; Set these in ./profiles.clj
             :dev-env-vars  {}
             :test-env-vars {}

             :dev  [:dev-default  :dev-env-vars]
             :test [:test-default :test-env-vars]
             :production [:production-default] })

我想我的困惑是:当我在开发环境中运行服务器时,为什么我会收到关于midje的错误?

1 个答案:

答案 0 :(得分:2)

您需要使用lein with-profile +dev ring server。如果您使用lein with-profile dev ring server(请注意开发前不存在+),则开发人员配置文件将使用并替换默认值

有更多关于调用Leiningen的信息,其中不同的个人资料有效here

您的src路径(news / routes / headlines_test.clj)上似乎也有一个测试clojure文件,可能需要midje。您需要将其从src中删除并将其放在另一个目录中,或者在调用lein ring服务器时需要包含测试配置文件,即lein with-profile +dev,+test ring server