Clojure 警告:“结果集序列已存在于 clojure.core 中”
我是 Clojure 的新手,正在使用 Noir 框架构建一个 Web 应用程序(与 Compojure 非常相似,事实上我认为它是具有不同请求处理程序层的 Compojure)。当我导入 JDBC 库时,我收到一条警告:
WARNING: resultset-seq already refers to: #'clojure.core/resultset-seq in namespace: webapp.models.database, being replaced by: #'clojure.java.jdbc/resultset-seq
我是否必须接受此警告,或者有解决方法吗?我使用以下方式导入 JDBC 库:
(use 'clojure.java.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
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以通过指定要导入的确切绑定来避免该问题:
另一个选项是
:exclude
有问题的绑定:您也可以只使用
require
代替:兼容性方面,
require
可以说是最安全的。使用:only
只是稍微不太干净,但仍然是一个很好的方法(并且在出现问题时很容易修复)。排除当前有问题的绑定可能是解决问题的最不适合未来的方法,因为其他冲突的绑定可能随时出现,并且跟踪从何处导入的内容可能很棘手。You can avoid the problem by specifying the exact bindings to be imported:
Another option is to
:exclude
the offending binding:You can also just use
require
instead: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.java.jdbc 包中的 resultset-seq,您可以排除它:
或者更好的是,
其中 f1、f2、f3 是您实际需要的东西。
然后使用 jdbc/resultset-seq
或者您可以:
然后使用 clojure.java.jdbc/reusltset-seq
There are lots of options. What this warning means is, that you are replacing an already defined symbol with a definition from different package. In this case, it looks like this is a variable that you've defined, right? If so the easiest solution might be to just rename it in your code.
Or if you don't need the resultset-seq from clojure.java.jdbc package you can exclude it:
or better yet,
where f1, f2, f3 are the things you're actually need.
and then use jdbc/resultset-seq
Or you can just:
and then use clojure.java.jdbc/reusltset-seq
除了其他优秀的答案之外,如果您想要 jdbc resultset-seq 而不是核心的,您可以将后者排除在当前 ns 之外:
In addition to the other excellent answers, if you want the jdbc resultset-seq instead of the core one, you can exclude the latter from being brought into the current ns: