草庐IT

scala - 错误 : class file needed by ValidDateOrNumericTypeHolder, 需要 RegisterJodaTimeConversionHelpers() - 它没有希望,我找不到导入

coder 2023-11-03 原文

也许我是瞎子之类的,但我找不到我需要的导入。我在玩 scala + mongodb。一切都很好,我只是这个 JodaTimer 有一些问题。 In this tutorial你必须像这样导入它:

import com.mongodb.casbah.conversions.scala._
RegisterJodaTimeConversionHelpers()

好吧,我找不到它。我只有:

import com.mongodb.casbah.commons._
import com.mongodb.casbah.util._
import com.mongodb.casbah.query._
//...

嗯,没有“转换”。还有另一种方法来获得这个 JodaTimer 吗?因为没有 Joda,您无法连接到数据库,所以您会收到错误消息:

    import com.mongodb.casbah.Imports._

    object Main {
      def main(args: Array[String]) {

        val connection = MongoConnection() //error
        //val object1 = MongoDBObject("one" -> "hi","two" -> 42)
        //...
      }
    }

***1.) class file needed by ValidDateOrNumericTypeHolder is missing.***

***2.) reference value joda of package org refers to nonexisting symbol.***

有什么想法吗?谢谢

编辑: 如果您阅读 tutorial-site

**1.2.5. Casbah Modules:**

*...*

*Package: com.mongodb.casbah.commons*

*Dependencies: mongo-java-driver, scalaj-collection, scalaj-time, JodaTime, slf4j-api*

*...*

我有公地,但没有 JodaTime。我不明白如何设置这个 jodatime。我需要魔法吗?

最佳答案

可能是文档中的错误。我正在使用 casbah 2.1.2 并且我使用这样的转换(注意 casbah 和转换之间的共同点):

com.mongodb.casbah.commons.conversions.scala.RegisterJodaTimeConversionHelpers()

如果你需要JodaTime,我猜你自己肯定对它有依赖。

关于scala - 错误 : class file needed by ValidDateOrNumericTypeHolder, 需要 RegisterJodaTimeConversionHelpers() - 它没有希望,我找不到导入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7886662/

有关scala - 错误 : class file needed by ValidDateOrNumericTypeHolder, 需要 RegisterJodaTimeConversionHelpers() - 它没有希望,我找不到导入的更多相关文章

随机推荐