【问题标题】:Intellij Scala library dependency not found未找到 Intellij Scala 库依赖项
【发布时间】:2017-12-05 02:32:06
【问题描述】:

我是 Scala 和 IntelliJ 的新手。我正在尝试编写一个 JSON 程序,但它在下面有编译错误。我正在使用json4s-core_2.9.1-3.0.0

错误:(37, 14) Class com.fasterxml.jackson.core.JsonParseException not 找到 - 继续使用存根。错误:(37, 14) 类 com.fasterxml.jackson.core.JsonProcessingException 未找到 - 继续存根。错误:(37, 14) 类 com.fasterxml.jackson.core.JsonGenerationException 未找到 - 继续存根。

在我的设置文件中,我有:

scalaVersion := "2.12.4"

libraryDependencies += "org.json4s" %% "json4s-jackson" % "{latestVersion}"

libraryDependencies += "com.fasterxml.jackson.core" % "jackson.core" % "{latestVersion}"
libraryDependencies += "com.fasterxml.jackson.core" % "JsonParseException" % "{latestVersion}"
libraryDependencies += "com.fasterxml.jackson.core" % "JsonProcessingException" % "{latestVersion}"
libraryDependencies += "com.fasterxml.jackson.core" % "JsonGenerationException" % "{latestVersion}"

会出什么问题?任何想法都值得赞赏。谢谢!

【问题讨论】:

    标签: scala intellij-idea


    【解决方案1】:

    json4s-core_2.9.1-3.0.0 看起来像是一个非常过时的版本,可与 Scala 2.9.1 一起使用,但您使用的是 Scala 版本 2.12.4。您需要与 Scala 2.12.4 一起使用的最新版本的 json4s(它基于 Maven 是 json4s 3.5.3)。从json4s install instructions 我认为您只需要在build.sbt 文件中添加以下内容。

    libraryDependencies ++= Seq(
      "org.json4s" %% "json4s-jackson" % "{latestVersion}" 
    )
    

    这应该会自动获取最新版本的json4s-core 以及json4s-jackson 库。

    【讨论】:

    • 啊……这就是原因。我抓住了更新 2.12.3.5.3。
    • 太棒了!如果这解决了您的问题,请记住接受答案。
    • 啊……这就是原因。我抓住了更新 2.12.3.5.3 并将“ libraryDependencies += "org.json4s" %% "json4s-AST" % "{latestVersion}"" 添加到最佳文件中。现在,我得到一个不同的错误(类路径中缺少符号'term org.json4s.JsonAST')。有没有办法弄清楚?你怎么知道依赖格式(如 org.json4s 或 json4s-jackson)?非常感谢!
    • 想通了。新的更新有一组不同的函数参数。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-10
    • 1970-01-01
    • 2015-10-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多