gpt4 book ai didi

clojure - 使用 Lein 和 Ring 在 Clojure 中丢失 *out*

转载 作者:行者123 更新时间:2023-12-04 15:22:48 26 4
gpt4 key购买 nike

我正在运行 Lein 2 和苹果酒 0.7.0。我制作了一个使用 ring/run-jetty 启动的示例 ring 应用程序。

(ns nimbus-admin.handler
(:require [compojure.core :refer :all]
[compojure.handler :as handler]
[clojure.tools.nrepl.server :as nrepl-server]
[cider.nrepl :refer (cider-nrepl-handler)]
[ring.adapter.jetty :as ring]
[clojure.tools.trace :refer [trace]]
[ring.util.response :refer [resource-response response redirect content-type]]
[compojure.route :as route])
(:gen-class))


(defroutes app-routes
(GET "/blah" req "blah")
(route/resources "/")
(route/not-found (trace "not-found" "Not Found")))

(def app (handler/site app-routes))

(defn start-nrepl-server []
(nrepl-server/start-server :port 7888 :handler cider-nrepl-handler))

(defn start-jetty [ip port]
(ring/run-jetty app {:port port :ip ip}))

(defn -main
([] (-main 8080 "0.0.0.0"))
([port ip & args]
(let [port (Integer. port)]
(start-nrepl-server)
(start-jetty ip port))))

然后用苹果酒连接到它,如:
cider-connect 127.0.0.1 7888

我可以在 emacs 中导航到我的站点和 eval 表单,它会更新我的 nrepl session 中正在运行的内容,这很棒。

我看不到输出,无论是 (print "test") (println "test") (trace "out" 1)
最后,我的项目文件:
(defproject nimbus-admin "0.1.0"
:description ""
:url ""
:min-lein-version "2.0.0"
:dependencies [[org.clojure/clojure "1.6.0"]
[com.climate/clj-newrelic "0.1.1"]
[com.ashafa/clutch "0.4.0-RC1"]
[ring "1.3.1"]
[clj-time "0.8.0"]
[midje "1.6.3"]
[org.clojure/tools.nrepl "0.2.6"]
[ring/ring-json "0.3.1"]
[org.clojure/tools.trace "0.7.8"]
[compojure "1.1.9"]
[org.clojure/data.json "0.2.5"]
[org.clojure/core.async "0.1.346.0-17112a-alpha"]
]
:plugins [[lein-environ "1.0.0"]
[cider/cider-nrepl "0.7.0"]]
:main nimbus-admin.handler)

我开始网站 lein run
编辑
我可以看到输出,仅在使用 (.println System/out msg)

最佳答案

你试过了吗(.println System/out msg) ?我有同样的问题,这对我有用。

关于clojure - 使用 Lein 和 Ring 在 Clojure 中丢失 *out*,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22365741/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com