【问题标题】:Attempting to call unbound fn: #'datoteka.core/to-file尝试调用未绑定的 fn:#'datoteka.core/to-file
【发布时间】:2018-06-29 18:41:30
【问题描述】:

我对 clojure 很陌生,我收到以下错误:

Caused by: java.lang.IllegalStateException: Attempting to call unbound fn: #'datoteka.core/to-file
at clojure.lang.Var$Unbound.throwArity(Var.java:45)
at clojure.lang.AFn.invoke(AFn.java:32)
at package.auth_monitor$start_monitor_thread.invokeStatic(auth_monitor.clj:43)
at package.auth_monitor$start_monitor_thread.invoke(auth_monitor.clj:38)
at package.auth_monitor$start_monitor.invokeStatic(auth_monitor.clj:62)
at package.auth_monitor$start_monitor.invoke(auth_monitor.clj:49)
at package.auth_monitor$fn__11768.invokeStatic(auth_monitor.clj:71)
at package.auth_monitor$fn__11768.invoke(auth_monitor.clj:70)

代码是:

42. (let [^TailerListener listener (make-listener)
43.    ^File file (fs/to-file path)
44.    ^Tailer tailer (Tailer. file listener 1000 true)]
45. (doto (Thread. tailer)
46.  (.setDaemon false)
47.  (.start)))

【问题讨论】:

  • 确实,datoteka.core 中没有函数to-file。你能解释一下你想要达到的目标吗?
  • 我继承了项目,但我猜之前的开发者试图创建一个线程来监听文件的变化

标签: clojure


【解决方案1】:

我假设您正在使用 Datoteka 库。尝试使用file 函数根据路径获取File 对象(to-file 似乎是一个错误的名称):

(let [^TailerListener listener (make-listener)
      ^File file (fs/file path)
      ^Tailer tailer (Tailer. file listener 1000 true)]
  (doto (Thread. tailer)
    (.setDaemon false)
    (.start)))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-23
    • 1970-01-01
    • 2019-02-21
    • 2017-01-04
    • 1970-01-01
    • 1970-01-01
    • 2018-08-07
    相关资源
    最近更新 更多