使用 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屋!