Clojure的:要求和无用 [英] Clojure's :require and Instaparse
问题描述
我正在尝试将 instaparse 库用于我的clojure项目.我在项目依赖项中使用leiningen 2.0和clojure 1.5.1.我将instaparse添加到我的项目依赖项中,如下所示:
I am trying to use instaparse lib for my clojure project. I use leiningen 2.0 and clojure 1.5.1 in my project dependencies. I add instaparse to my project dependencies as follow:
(defproject bachelor "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.5.1"]
[org.clojure/clojure-contrib "1.2.0"]
[instaparse "1.1.0"]])
这就是我试图提供该lib的地方:
And that is my source where i'm trying to require that lib:
(ns bachelor.data
(:require [clojure.string :as str])
(:require [instaparse.core :as insta])
(:use [clojure.contrib.generic.math-functions])
)
当我尝试编译时,出现以下错误消息:
When I try to compile that I get following error message:
cd c:/bachelor/src/bachelor.data/1编译器注释:
cd c:/bachelor/src/bachelor.data/ 1 compiler notes:
未知位置:错误:java.io.FileNotFoundException:无法 在以下位置找到instaparse/core__init.class或instaparse/core.clj 类路径:
Unknown location: error: java.io.FileNotFoundException: Could not locate instaparse/core__init.class or instaparse/core.clj on classpath:
company.clj:1:1:错误:java.io.FileNotFoundException:无法 在以下位置找到instaparse/core__init.class或instaparse/core.clj 类路径:(company.clj:1)
company.clj:1:1: error: java.io.FileNotFoundException: Could not locate instaparse/core__init.class or instaparse/core.clj on classpath: (company.clj:1)
编译失败.
我检查了项目的类路径,并认为应该在其中找到instaparse.
I checked classpath for my project and I think that instaparse should be found there.
lein类路径
lein classpath
C:\ bachelor \ test; C:\ bachelor \ src; C:\ bachelor \ dev-resources; C:\ bachelor \ resources; C:\ bachelor \ target \ classes; C:\ Users \ Maciej.m2 \ repository \ instaparse \ instaparse \ 1.1.0 \ instaparse-1.1.0.jar; C:\ Users \ Mac iej.m2 \ repository \ org \ clojure \ clojure-contrib \ 1.2.0 \ clojure-contrib-1.2.0.jar; C:\ Users \ Maciej.m2 \ repository \ org \ clojure \ clojure \ 1.5.1 \ clojure -1.5.1.jar
C:\bachelor\test;C:\bachelor\src;C:\bachelor\dev-resources;C:\bachelor\resources;C:\bachelor\target\classes;C:\Users\Maciej.m2\repository\instaparse\instaparse\1.1.0\instaparse-1.1.0.jar;C:\Users\Mac iej.m2\repository\org\clojure\clojure-contrib\1.2.0\clojure-contrib-1.2.0.jar;C:\Users\Maciej.m2\repository\org\clojure\clojure\1.5.1\clojure-1.5.1.jar
知道我在做什么错吗?
更新
我更新了lein类路径的结果.以前,我粘贴了旧结果.
I updated result for lein classpath. Earlier, I've pasted old result.
推荐答案
我发现了问题所在.我当时用leiningen创建项目,但是用Clojure-box或Clooj开发源代码.我也在尝试使用这些工具来编译我的源代码,这是错误的.当您运行此类IDE时,它会加载自己的类路径,这就是为什么它找不到我要使用的库的原因.现在,我用
I've found out what was wrong. I was creating project with leiningen but develop source with Clojure-box or Clooj. I was also trying to compile my source with that tools and it was mistake. When you run such IDE it loads that's own classpath and that is why it could not find library I'd like to use. Now I compile my src with
lein编译
lein compile
并在
lein repl
lein repl
一切都很好.
这篇关于Clojure的:要求和无用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!