91

我正在将 Joda Time 存储库添加到 SBT

libraryDependencies ++= Seq(
  "joda-time"         % "joda-time"           % "2.1"
)

然后我像这样愉快地使用它:

 val ymd = org.joda.time.format.DateTimeFormat.forPattern("yyyyMMdd")
  ymd.parseDateTime("20121212")

但是,当我在 SBT 中编译项目时,我感到很讨厌:

[warn] Class org.joda.convert.FromString not found - continuing with a stub.
[warn] Caught: java.lang.NullPointerException while parsing annotations in /home/jack/.ivy2/cache/joda-time/joda-time/jars/joda-time-2.1.jar(org/joda/time/DateTime.class)
[error] error while loading DateTime, class file '/home/jack/.ivy2/cache/joda-time/joda-time/jars/joda-time-2.1.jar(org/joda/time/DateTime.class)' is broken
[error] (class java.lang.RuntimeException/bad constant pool tag 10 at byte 42)

我尝试了 joda-time 的 2.0 版本,但得到了同样的错误。

4

2 回答 2

177

Add this dependency:

"org.joda" % "joda-convert" % "1.8.1"

It's an optional dependency of joda-time. I had to add it in my own project for the scala compiler to accept working with the joda-time jar.

Your issue seems to be the same.

Version is as at time of editing, latest versions can be found here

于 2012-12-13T09:07:07.607 回答
1

我遇到了类似的问题:

[warn] Class net.jcip.annotations.NotThreadSafe not found - continuing with a stub.
[warn] Caught: java.lang.NullPointerException while parsing annotations in ~/.ivy2-p2/cache/org.opensaml/xmltooling/jars/xmltooling-1.3.4.jar(org/opensaml/xml/util/IDIndex.class)
[error] error while loading AttributeMap, class file '~/.ivy2-p2/cache/org.opensaml/xmltooling/jars/xmltooling-1.3.4.jar(org/opensaml/xml/util/AttributeMap.class)' is broken
[error] (class java.lang.RuntimeException/bad constant pool index: 0 at pos: 12058)

显式添加依赖jcip-annotations-1.0.jar项解决了该问题。

于 2013-10-16T17:59:40.183 回答