[英]Unable to run clara rules clojure program from eclipse
I am trying to learn clara rules - clojure which is present in " http://www.clara-rules.org/docs/firststeps/ " 我正在尝试学习clara规则-“ http://www.clara-rules.org/docs/firststeps/ ”中提供的clojure
(ns with-mongo.clara.example
(:require [clara.rules :refer :all]))
(defrecord SupportRequest [client level])
(defrecord ClientRepresentative [name client])
(defrule is-important
"Find important support requests."
[SupportRequest (= :high level)]
=>
(println "High support requested!"))
(defrule notify-client-rep
"Find the client representative and request support."
[SupportRequest (= ?client client)]
[ClientRepresentative (= ?client client) (= ?name name)]
=>
(println "Notify" ?name "that"
?client "has a new support request!"))
Executing the following in REPL 在REPL中执行以下操作
(-> (mk-session 'with-mongo.clara.example)
(insert (->ClientRepresentative "Alice" "Acme")
(->SupportRequest "Acme" :high))
(fire-rules))
But what I get in eclipse is CompilerException java.lang.RuntimeException: Unable to resolve symbol: fire-rules in this context, compiling:(C:\\Users\\x\\AppData\\Local\\Temp\\form-init8304513432405616575.clj:1:2) 但是我在eclipse中得到的是CompilerException java.lang.RuntimeException:无法解析符号:在这种情况下的火灾规则,编译:(C:\\ Users \\ x \\ AppData \\ Local \\ Temp \\ form-init8304513432405616575.clj:1: 2)
Does anyone has any details on it? 有人有任何细节吗?
You have not require
d clara.rules
in your REPL beforehand. 您
require
在REPL中预先提供d clara.rules
。 Eg run 例如运行
(require '[clara.rules :refer :all]))
first. 第一。 (or run your own
ns
there first - that depends on how you want to run/use the REPL and what eclipse allows you to use (non-eclipse-user here)) (或者首先在那儿运行自己的
ns
这取决于您要如何运行/使用REPL以及什么eclipse允许您使用(此处为非eclipse用户))
So why does it complain about fire-rules
and not mk-session
? 那么,为什么它抱怨
fire-rules
而不是mk-session
呢? That is due to the way the threading macro ->
works. 那是由于线程宏
->
工作方式。 If you macroexpand
your code, that throws, you will see, that fire-rules
is actually the first function called. 如果您对代码进行
macroexpand
,那么您将看到, fire-rules
实际上是第一个调用的函数。
The issue I was facing was due to the version mismatches 我面临的问题是由于版本不匹配
:dependencies [[org.clojure/clojure "1.6.0"]
[com.novemberain/monger "3.0.0-rc2"]
[ring "1.4.0"]
[ring/ring-json "0.4.0"]
[compojure "1.4.0"]
[com.cerner/clara-rules "0.19.0"]])
I was using 1.6.0 for clojure and after updating to clojure "1.7.0". 我正在使用1.6.0制作Clojure,并更新到Clojure“ 1.7.0”之后。 Clara rules are getting triggered.
克拉拉规则被触发。
:dependencies [[org.clojure/clojure "1.7.0"]
[com.novemberain/monger "3.0.0-rc2"]
[ring "1.4.0"]
[ring/ring-json "0.4.0"]
[compojure "1.4.0"]
[com.cerner/clara-rules "0.19.0"]])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.