2013-02-08 63 views
1

Iam现在尝试HOURS并且无法找出问题所在。Iam新增clojure并尝试制作一个简单的flickr客户端。 但我对不同的图书馆有这个问题......我想我犯了一个普遍的错误。clojure - 找不到错误?

目前,我尝试使用OAuth与此lib目录下:https://github.com/mattrepl/clj-oauth

lein new projectname 

和我project.clj看起来是这样的:

(defproject flickr "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.4.0"] 
       [clj-oauth "1.4.0"]]) 

加入CLJ-的oauth2后,我跑:

lein deps 

And my core.clj:

(ns flickr.core) 
    (require ['oauth.client :as 'oauth]) 


(def consumer-key "0000") 
(def consumer-secret "0000") 

(def consumer (oauth.client/make-consumer <consumer-token> 
           <consumer-token-secret>        
           "http://www.flickr.com/services/oauth/request_token" 
           "http://www.flickr.com/services/oauth/access_token" 
           "http://www.flickr.com/services/oauth/authorize" 
           :hmac-sha1)) 

现在当我尝试运行它:

lein run 

我得到:

FileNotFoundException Could not locate oauth/client__init.class or oauth/client.clj on classpath: clojure.lang.RT.load (RT.java:432) 

有没有人有一个想法,问题出在哪里? 也从github repo下载了oauth源文件,将其构建并添加到我的$ PATH变量中,但仍然出现相同的错误。

任何帮助,将不胜感激! 谢谢!

回答

2

首先,lein run查找主名称空间,其名称必须使用:main键在project.clj中指定; add :main flickr.core there

然后你需要-main函数flickr.core。改变你的命名空间声明,并添加功能如下:

(ns flickr.core 
    (:require [clj-oauth2.client :as oauth])) 

(defn -main [] 
    (println oauth/get-access-token)) 

然后,

$ lein run 
;=> #<client$get_access_token [email protected]> 

这工作对我来说是一种“命名空间冒烟测试”,你应该能够从那里走。

(最后要注意,你的发展会更快,如果你测试这些种种的事情REPL,而不是用“雷音运行。”)

+0

听起来不错,谢谢!我明天会试一试... – Nico 2013-02-08 23:40:01

1

这似乎有一个与你的依赖关系的混乱。根据Clojars,你使用的图书馆clj-oauth2是这个GitHub项目https://github.com/DerGuteMoritz/clj-oauth2,而不是你在问题中链接到的那个。

如果你想要最新的clj-oauth,那么依赖关系应该是[clj-oauth "1.4.0"](对于最新版本)。如果你需要clj-oauth2那么上面的GitHub链接应该是参考。

+0

谢谢你的提示。 Iam实际上使用了clj-oauth。 clj-oauth2来自以前的测试。 – Nico 2013-02-08 23:37:11