使用Datomic的Compojure无法编译

时间:2019-09-12 14:27:47

标签: clojure datomic

我正在设置compojure应用程序,并且希望使用datomic作为数据库-但是,一旦添加client-pro依赖项,我的应用程序将无法运行。

这就是我所做的:

  1. 注册帐户
  2. 下载了datomic-pro
  3. 创建了一个transactor.properties并用我在电子邮件中收到的license-key对其进行了更新
  4. bin/transactor transactor.properties
  5. 打开另一个标签,并创建一个数据库:
(require ‘[datomic.api :as d])
(def db-uri “datomic:dev://localhost:4334/hello”)
(d/create-database db-uri)
  1. 在另一个标签上启动对等服务器
bin/run -m datomic.peer-server -h localhost -p 8998 -a myaccesskey,mysecret -d hello,datomic:dev://localhost:4334/hello
  1. [com.datomic/client-pro “0.8.28”]添加到了我的依赖项中

运行lein ring server时出现此错误:

Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.util.thread.NonBlockingThread

1 个答案:

答案 0 :(得分:0)

速览

不是直接的答案,但是,如果您只是想快速入门Datomic,可以在这里克隆Tupelo Datomic仓库:

https://github.com/cloojure/tupelo-datomic

它包括Datomic Free的预配置版本。只需运行lein test即可查看实际效果。然后,您可以添加自己的代码。


关于码头

您可能只需要Erwin的答案。另一种可能性是,您可能需要在特定版本中添加传递依赖,并在其他版本上使用:exclude。另请注意,在project.clj中,重要的部门必须列在文件的顶部,因为这些部门的版本(及其过渡部门的版本)将被覆盖取决于稍后指定的版本。

project.clj中,我有一个项目的Lein Deps:

  :exclusions [cheshire
               com.cognitect/transit-clj
               com.cognitect/transit-cljs
               com.cognitect/transit-java
               com.cognitect/transit-js
               com.fasterxml.jackson.core/jackson-core
               com.fasterxml.jackson.core/jackson-databind
               com.fasterxml.jackson.dataformat/jackson-dataformat-cbor
               com.fasterxml.jackson.dataformat/jackson-dataformat-smile
               joda-time/joda-time
               org.eclipse.jetty/jetty-server]

  :dependencies [
                 ; fundamental items must come first to override later transitive dependencies
                 [cheshire "5.8.1"]
                 [com.cognitect/transit-clj "0.8.313"]
                 [com.cognitect/transit-cljs "0.8.256"]
                 [com.cognitect/transit-java "0.8.337"]
                 [com.cognitect/transit-js "0.8.861"]
                 [com.fasterxml.jackson.core/jackson-core "2.9.9"]
                 [com.fasterxml.jackson.core/jackson-databind "2.9.9"]
                 [com.fasterxml.jackson.dataformat/jackson-dataformat-cbor "2.9.9"]
                 [com.fasterxml.jackson.dataformat/jackson-dataformat-smile "2.9.9"]
                 [joda-time/joda-time "2.10.3"]
                 [org.clojure/clojure "1.10.1"]
                 [org.eclipse.jetty/jetty-server "9.4.19.v20190610"]

然后列出第二层部门:

                 ; high-priority libs, ensure these versions override any transitive dependency versions
                 [binaryage/devtools "0.9.10"]
                 [binaryage/oops "0.7.0"]
                 [com.andrewmcveigh/cljs-time "0.5.2"]
                 [com.cemerick/url "0.1.1"]
                 [org.clojure/core.async "0.4.500" :exclusions [org.clojure/tools.reader]]
                 [org.clojure/core.match "0.3.0"]
                 [org.clojure/test.check "0.9.0"]
                 [org.clojure/tools.cli "0.4.2"]
                 [org.clojure/tools.logging "0.5.0"]
                 [org.clojure/tools.nrepl "0.2.13"] ; #todo #awt upgrade => [nrepl "0.3.1"] from https://github.com/nrepl/nrepl
                 [prismatic/schema "1.1.11"]
                 [tupelo "0.9.144"]
                 [venantius/accountant "0.2.4"]

然后是第三层部门:

                 ; "normal" dependency libs, whose transitive dependencies can be overridden by previous libs
                 [ch.qos.logback/logback-classic "1.2.3"]
                 [clj-http "3.10.0"]
                 [clj-time "0.15.1"] ; #todo switch to java.time & tupelo.java-time
                 [cljsjs/cytoscape "3.1.4-0"]
                 [com.amazonaws/aws-java-sdk "1.11.602" :exclusions [joda-time]]
                 [com.taoensso/carmine "2.19.1"]
                 [compojure "1.6.1"]
                 [cprop "0.1.14"]
                 [expound "0.7.2"]
                 [funcool/struct "1.4.0"]
                 [io.janusplatform/janus-environment-config "1.8.7-SNAPSHOT"]
                 [io.janusplatform/janus-logging-java "1.0.11-SNAPSHOT" :exclusions [com.google.guava/guava]]
                 [io.janusplatform/janus-resource-connector "4.3.0-SNAPSHOT"]
                 [jayq "2.5.5"]
                 [luminus-jetty "0.1.7" ]
                 [luminus-nrepl "0.1.6"]
                 [luminus/ring-ttl-session "0.3.3"]
                 [markdown-clj "1.10.0"]
                 [metosin/muuntaja "0.2.1"]
                 [metosin/ring-http-response "0.9.1"]
                 [metosin/spec-tools "0.10.0"]
                 [metosin/scjsv "0.5.0"]
                 [metrics-clojure-ring "2.10.0"]
                 [mount "0.1.16"]
                 [org.webjars/bootstrap "4.3.1"]
                 [org.webjars/font-awesome "5.9.0"]
                 [overtone/at-at "1.2.0"]
                 [ring-webjars "0.2.0"]
                 [ring/ring-codec "1.1.2"]
                 [ring/ring-core "1.7.1"]
                 [ring/ring-defaults "0.3.2"]
                 [ring/ring-json "0.4.0"]
                 [throttler "1.0.0"]

和一些杂项部门:

                 [amazonica "0.3.145" :exclusions [com.amazonaws/aws-java-sdk
                                                   com.fasterxml.jackson.core/jackson-core
                                                   com.fasterxml.jackson.dataformat/jackson-dataformat-cbor
                                                   org.apache.httpcomponents/httpclient]]    ; #todo do we really need all these exclusions???

                 [cljs-ajax "0.8.0" :exclusions [cheshire
                                                 com.cognitect/transit-clj
                                                 com.cognitect/transit-java
                                                 org.apache.httpcomponents/httpasyncclient
                                                 org.apache.httpcomponents/httpcore
                                                 org.msgpack/msgpack]]    ; #todo do we really need all these exclusions???

                 [org.springframework/spring-webmvc "5.1.8.RELEASE" :exclusions [org.springframework/spring-jcl
                                                                                 org.springframework/spring-aop]]
                 ]

您还可以看到我必须排除Jetty,以防止传递依赖引入错误的版本,然后专门添加我想要的版本。