错误:scala:Scala 编译器库中没有“scala-library*.jar”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24019834/
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
Error: scala: No 'scala-library*.jar' in Scala compiler library
提问by jkschneider
Environment:Play 2.3.0/Scala 2.11.1/IntelliJ 13.1
环境:Play 2.3.0/Scala 2.11.1/IntelliJ 13.1
I used Typesafe Activator 1.2.1 to create a new project with Scala 2.11.1. After the project was created, I ran gen-idea. The generated IDEA project fails to compile with the error:
我使用 Typesafe Activator 1.2.1 用 Scala 2.11.1 创建一个新项目。创建项目后,我运行gen-idea. 生成的IDEA项目编译失败,报错:
Error: scala: No 'scala-library*.jar' in Scala compiler library in test
Error: scala: No 'scala-library*.jar' in Scala compiler library in test
Am I doing something wrong? Workaround?
难道我做错了什么?解决方法?


采纳答案by Vladimir Matveev
Since IDEA 13 you should use SBT support which is bundled with Scala plugin.
从 IDEA 13 开始,您应该使用与 Scala 插件捆绑在一起的 SBT 支持。
With it there is no need to add third-party SBT plugins and run special commands; just import the project using "File -> Import project..." menu item, and it will automatically load SBT project structure and its dependencies.
有了它,无需添加第三方 SBT 插件和运行特殊命令;只需使用“文件 -> 导入项目...”菜单项导入项目,它就会自动加载 SBT 项目结构及其依赖项。
回答by Searene
回答by Russell
I had the same issue with the .idea files generated by ./activator idea with play 2.3. A quick fix is to look in "Project Structure->modules" and note the name of the compiler library. For me it was "SBT: scala2.11.1". The look in "Project Structure->Libraries" and check the contents of this library. It should contain scala-compiler.jar, scala-library.jar, scala-reflect.jar. If this libraries are not present, add them (in my case they are located in ~/.sbt/boot/scala-2.11.1/lib).
我对 ./activator idea 和 play 2.3 生成的 .idea 文件有同样的问题。快速修复是查看“项目结构->模块”并注意编译器库的名称。对我来说是“SBT:scala2.11.1”。查看“项目结构->库”并检查该库的内容。它应该包含 scala-compiler.jar、scala-library.jar、scala-reflect.jar。如果此库不存在,请添加它们(在我的情况下,它们位于 ~/.sbt/boot/scala-2.11.1/lib)。
回答by Alex Shcherbyna
For IDEA 15 and project exported from Activator 1.3.5 only Russell's solution helped at the moment. I have fixed scala compiler library with adding 3 libraries located in ~/.sbt/boot/scala-2.11.1/lib to library's compiler classpath and classes. After indexing project I moved this library to global libraries of IDEA and it was saved there.
对于 IDEA 15 和从 Activator 1.3.5 导出的项目,目前只有 Russell 的解决方案有所帮助。我已经修复了 Scala 编译器库,将位于 ~/.sbt/boot/scala-2.11.1/lib 中的 3 个库添加到库的编译器类路径和类中。索引项目后,我将此库移至 IDEA 的全局库,并将其保存在那里。
回答by ketankk
I had the same issue.
我遇到过同样的问题。
If you are building your project using external sbti.e sbt compilethen it will create or add dependencies in libraries(all external dependency also) and scala sdk will be added as SBT:scala*based on version of your scala.
So you can remove SDKwith SBT as prefix and add proper SDK through Intellij.
如果您使用外部sbtie构建项目,sbt compile那么它将在库中创建或添加依赖项(所有外部依赖项也是),并且 scala sdk 将SBT:scala*根据您的 scala 版本添加。因此,您可以SDK使用 SBT 作为前缀删除并通过 Intellij 添加适当的 SDK。
File->Project Structure->Libraries
Remove SBT SDK and add it manually.
删除 SBT SDK 并手动添加。
回答by wiseco68
For me with IDEA 12, I fixed this issue when I unchecked the box for "Use external build" in Settings.Compiler.
对于使用 IDEA 12 的我来说,当我在 Settings.Compiler 中取消选中“使用外部构建”框时,我解决了这个问题。

