clojure - 使用 lein 将依赖项添加到 clojure 项目

标签 clojure dependencies clojurescript leiningen reagent

尽管添加了 desired dependency到我的project.clj 文件,

(defproject word-tree "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}

  :dependencies [[org.clojure/clojure "1.10.1"]
                 [org.clojure/clojurescript "1.10.520"]
                 [clojure-opennlp "0.5.0"] ; <----------------------here
                 [reagent "0.8.1"]]
 ...

我无法访问依赖项提供的功能。

在我的一个文件中引用命名空间后,

(ns word-tree.suffix-tree
  (:require [clojure.string :as str]
            [opennlp.nlp :as nlp])) ; <-----this is the namespace of the dependency

我收到此错误:

No such namespace: opennlp.nlp, could not locate opennlp/nlp.cljs, opennlp/nlp.cljc, or JavaScript source providing "opennlp.nlp"

最奇怪的部分是当我运行 lein deps :tree 时依赖关系出现了!

$ lein deps :tree
...
[cider/piggieback "0.4.1" :scope "test"]
 [cljfmt "0.5.7"]
   [rewrite-clj "0.5.2"]
   [rewrite-cljs "0.4.3"]
 [clojure-complete "0.2.5" :exclusions [[org.clojure/clojure]]]
 [clojure-opennlp "0.5.0"] <------------------------------------------------here!!!
   [instaparse "1.4.9"]
   [org.apache.opennlp/opennlp-tools "1.9.0"]
 [figwheel-sidecar "0.5.19" :scope "test"]
...

对于我的项目,我真的想使用这个依赖项,但它不起作用。任何建议都将受到欢迎。谢谢。

最佳答案

在我看来,问题在于该库仅适用于 JVM 上的 Clojure,而您正尝试在 ClojureScript 项目上使用它。

No such namespace: opennlp.nlp, could not locate opennlp/nlp.cljs, opennlp/nlp.cljc, or JavaScript source providing "opennlp.nlp"

编译器尝试查找 ClojureScript 代码(扩展名 .cljs)或与 Clojure 和 ClojureScript(扩展名 .cljc)兼容或纯 JavaScript,但没有找到。

关于clojure - 使用 lein 将依赖项添加到 clojure 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58985920/

相关文章:

gradle - 在Gradle中动态添加依赖项?

python - 如何使用 Node 或 ClojureScript 在命令行上的当前文件夹中启动 Web 服务器?

xml - 如何仅从 clojure 中的嵌套 XML 中过滤某些值?

Clojure、方面、Defprotocol、Defrecord

maven - Maven依赖项org.apache.commons:commons-io和commons-io:commons-io有什么区别?

node.js - 如何使用 core.async 代替回调?

string - ClojureScript 中子字符串的索引

clojure - 如何将 figwheel 与环服务器集成以实现后端自动重新加载?

node.js - 使用 swank-js 和 clojure 设置 Emacs

java - 如何解决未解析的依赖关系 ':app@debug/compileClasspath' : Could not resolve com. google.android.gms :play-services-base:[15. 0.0, 16.0.0)