Clojure警告:"resultset-seq已存在于clojure.core中". [英] Clojure warning: "resultset-seq already exists in clojure.core"

查看:51
本文介绍了Clojure警告:"resultset-seq已存在于clojure.core中".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Clojure的新手,他是使用Noir框架构建Web应用程序的(非常类似于Compojure,实际上我认为它是带有不同请求处理程序层的Compojure).导入JDBC库时收到警告:

I'm new to Clojure and building a web app using the Noir framework (very similar to Compojure, in fact I think it's Compojure with a different request handler layer). I'm getting a warning when I import the JDBC library:

WARNING: resultset-seq already refers to: #'clojure.core/resultset-seq in namespace: webapp.models.database, being replaced by: #'clojure.java.jdbc/resultset-seq

我是否必须忍受此警告,否则是否可以解决?我正在使用以下方式导入JDBC库:

Do I have to live with this warning or is there a way around it? I'm importing the JDBC library using:

(use 'clojure.java.jdbc)

推荐答案

您可以通过指定要导入的确切绑定来避免此问题:

You can avoid the problem by specifying the exact bindings to be imported:

(use '[clojure.java.jdbc :only [insert-values transaction]])
(transaction
  (insert-values ...))

另一种选择是:exclude 有害的绑定:

Another option is to :exclude the offending binding:

(use '[clojure.java.jdbc :exclude [resultset-seq]])
(transaction
  (insert-values ...))

您也可以只使用 require :

(require '[clojure.java.jdbc :as db])
(db/transaction
  (db/insert-values ...))

关于前向兼容性, require 可以说是最安全的.使用:only 不太干净,但仍然是一种很好的方法(当中断时很容易修复).排除当前有问题的绑定可能是解决该问题的最不可靠的方法,因为其他冲突的绑定可能随时出现,并跟踪从何处导入的内容可能很棘手.

With regard to forward compatibility, require is arguably safest. Using :only is just slightly less clean but still a pretty good approach (and easy to fix when it breaks). Excluding the currently offending bindings is probably the least future-proof way of fixing the problem since other conflicting bindings can appear at any time and tracking down what is imported from where can be tricky.

这篇关于Clojure警告:"resultset-seq已存在于clojure.core中".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆