eclipse 在 Scala 2.11 中使用 util.parsing

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26691750/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:09:38  来源:igfitidea点击:

Using util.parsing in Scala 2.11

eclipsescalaimport

提问by Teemu Leivo

I have written a Scala program with Eclipse Scala IDE that uses scala.util.parsing.JSONand I would like to transform it to support Scala 2.11 version. In Scala 2.11 I get an error: error: object parsing is not a member of package util. I have found out that the parsing library is not anymore in the util package by default, but has to be downloaded separately here.

我已经使用 Eclipse Scala IDE 编写了一个 Scala 程序,scala.util.parsing.JSON我想将其转换为支持 Scala 2.11 版本。在 Scala 2.11 中,我收到一个错误: error: object parsing is not a member of package util. 我发现解析库默认不在 util 包中,而是必须在此处单独下载

I have downloaded that and tried to add it to my Eclipse project as a new source folder, but that didn't work out. The instructions are only for adding it to sbt, but I don't think that is relevant to me if I want to just use it in Eclipse.

我已经下载了它并尝试将它作为新的源文件夹添加到我的 Eclipse 项目中,但这没有成功。这些说明仅用于将它添加到 sbt,但如果我只想在 Eclipse 中使用它,我认为这与我无关。

Should I try to find a JAR file somewhere?

我应该尝试在某处找到 JAR 文件吗?

回答by Reid Spencer

Should I try to find a JAR file somewhere?

我应该尝试在某处找到 JAR 文件吗?

Yes, you should. :)

是的你应该。:)

And specifically, you should use this one (in SBT syntax):

具体来说,你应该使用这个(在 SBT 语法中):

libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.2"

The above line should be all you need to add to build.sbt if you're using SBT. If you want to manually add it to your project by downloading it, you can find it on Maven Central.

如果您使用 SBT,上面的行应该是您需要添加到 build.sbt 的全部内容。如果您想通过下载将其手动添加到您的项目中,您可以在Maven Central上找到它。

The scala-parser-combinators library was removed in 2.11 so that people who don't use it don't have to pay a price for having it in the scala runtime library. Consequently, people who do want to use it have to now explicitly include it in their build. Note that the XML library was similarly removed in 2.11 to its own library.

scala-parser-combinators 库在 2.11 中被删除,因此不使用它的人不必为在 scala 运行时库中使用它而付出代价。因此,想要使用它的人现在必须明确地将它包含在他们的构建中。请注意,XML 库在 2.11 中也被类似地移除到它自己的库中。