在使用需要名称空间的数据库函数时,我得到了一个FileNotFoundException。我只在使用持久数据空闲数据库时出现错误,但在使用内存数据库时不会出现错误。
(ns test.core
(:use [datomic.api :only [q db] :as d]))
(def uris ["datomic:mem://test"
"datomic:free://localhost:4334/test"])
(map
d/delete-database uris)
(map
d/create-database uris)
(def conns (map d/connect uris))
(defn test-entity []
[{:db/id #db/id[:db.part/db]
:test/test "hello"}])
(def db-function
#db/fn {:lang :clojure
:params [database]
:requires [[test.core :as c]]
:code (c/test-entity)})
(map
#(d/transact % [{:db/id #db/id[:db.part/user]
:db/ident :db-function
:db/fn db-function}])
conns)
(map
#(d/transact % [{:db/id #db/id[:db.part/db]
:db/ident :test/test
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db.install/_attribute :db.part/db}])
conns)
(comment
(db-function nil)
(d/transact (first conns) [[:db-function]])
(d/transact (second conns) [[:db-function]]))当您评估注释中的第一行和第二行时,这是很好的,但是当您评估第三行时,您会得到一个异常。
我需要在数据中配置一些东西,这样它才能“看到”我的项目吗?
发布于 2014-09-15 21:49:55
当您使用内存中的数据库时,事务处理机运行在与对等机相同的JVM实例中,因此使用相同的类路径。但使用免费数据库时,事务处理者在其自己的JVM实例中运行,并且不知道对等体中的名称空间。
您可以通过将jars放在lib/文件夹中来将它们添加到事务处理机类路径中。
https://stackoverflow.com/questions/24085382
复制相似问题