2016-10-28 26 views
0

我叫Clojure的java.lang.NoClassDefFoundError调用CLJ-时间/最后一天的最月

(clj-time.core/last-day-of-the-month 1999 2) 

(clj-time.core/number-of-days-in-the-month 1999 2) 

当两个罚球

java.lang.NoClassDefFoundError org/joda/time/DateTime$Property org.joda.time.DateTime.dayOfMonth (DateTime.java:1971) 

该文档说:

(defn last-day-of-the-month 
    ([^long year ^long month] 
     (last-day-of-the-month- (date-time year month))) 
    ([dt] 
     (last-day-of-the-month- dt))) 

(defn number-of-days-in-the-month 
    (^long [^DateTime dt] 
     (day (last-day-of-the-month- dt))) 
    (^long [^long year ^long month] 
     (day (last-day-of-the-month- (date-time year month))))) 

我犯了什么错误?

谢谢!

以下是我的项目设置和依赖:


(defproject xxx "0.1.2-SNAPSHOT" 
:description "" 
:dependencies [[org.clojure/clojure "1.8.0"] 

... 
      [clj-time "0.11.0"]   

...) 

,我在项目REPL试过这样:

clj-time=> clj-time.core/last-day-of-the-month 
#object[clj_time.core$last_day_of_the_month 0x6a86b560 "[email protected]"] 

上述结果是从REPL服务器获取我通过ssh进行连接。

当我在本地项目文件夹中运行lein repl,我能得到正确的结果:

xxx.core=> (clj-time.core/last-day-of-the-month 2016 2) 
#object[org.joda.time.DateTime 0x22a0534e "2016-02-29T00:00:00.000Z"] 
xxx.core=> (clj-time.core/number-of-days-in-the-month 2016 2) 
29 

我是新来的Clojure。这些信息有用吗?


重新启动repl后,现在问题就解决了。

回答

1

非常适合我。

project.clj:

(defproject clj "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.9.0-alpha13"] 
    [clj-time "0.12.0"] 
    ] 
    :java-source-paths ["/home/alan/xpr/src"] 
    :main ^:skip-aot clj.core 
    :target-path "target/%s" 
    :profiles {:dev  {:dependencies [[org.clojure/test.check "0.9.0"]] } 
      :uberjar {:aot :all}} 
) 

主程序:

(ns clj.core 
    (:require 
    [clj-time.core :as tm] 
)) 

(println :day (tm/last-day-of-the-month 1999 2)) 

(println :days (tm/number-of-days-in-the-month 1999 2)) 

(defn -main [& args]) 

结果:

~/clj > lein run  
:day #object[org.joda.time.DateTime 0x61884cb1 1999-02-28T00:00:00.000Z] 
:days 28 
+0

这是涉及CLJ-时间的版本?我无法编辑项目设置,因为我只是一个新角色,现在我们组中的许多人都使用该项目设置。 – cmal

+0

如果我将版本更改为“0.11.0”,它仍然很好用。也许你应该创建一个新的项目来测试,直到你得到它的工作。 –

+0

谢谢你的回答。但我的责任是ssh到远程服务器并在那里开发。我无权创建新项目,甚至无法重新启动流程。我是新来的lisp和repl风格的开发。是否有可能repl过程可能会被我之前的其他一些行为所污染,以便我可能调用一个可能不是原始函数的函数,所以我不能依赖函数的输出成为我期望的函数协作repl开发环境?谢谢。 – cmal