0

我在我的环服务器上看到一个错误,我开始使用 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 的错误?

4

1 回答 1

2

你需要使用lein with-profile +dev ring server. 如果您使用lein with-profile dev ring server(注意没有+before dev),将使用 dev 配置文件并替换 defaults

这里有更多关于使用不同配置文件调用 Leiningen 的信息

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

于 2015-01-19T13:16:19.127 回答