使用Scala的Joda Time发生类中断错误 [英] Class broken error with Joda Time using Scala
问题描述
我正在使用以下方式将Joda Time存储库添加到SBT中
I'm adding the Joda Time repository to SBT with
libraryDependencies ++= Seq(
"joda-time" % "joda-time" % "2.1"
)
然后我像这样高兴地使用它:
Then I merrily use it like this:
val ymd = org.joda.time.format.DateTimeFormat.forPattern("yyyyMMdd")
ymd.parseDateTime("20121212")
但是,当我在SBT中编译项目时,我会感到讨厌:
But, when I compile the project in SBT, I get a nasty:
[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版本,但遇到了相同的错误.
I tried the 2.0 version of joda-time, but get the same error.
推荐答案
添加此依赖项:
"org.joda"%"joda-convert"%"1.8.1"
"org.joda" % "joda-convert" % "1.8.1"
这是joda-time的可选依赖项. 我必须将其添加到我自己的项目中,以便Scala编译器接受使用joda-time jar的工作.
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
这篇关于使用Scala的Joda Time发生类中断错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!