IntelliJ 错误:Scala 145,错误:scalac:找不到 Scala 编译器 JAR
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36341257/
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
IntelliJ Bug: Scala 145, Error:scalac: Scala compiler JARs not found
提问by Orar
I try to compile a simple object in IntelliJ:
我尝试在 IntelliJ 中编译一个简单的对象:
object Test02 {
def main(args: Array[String]) {
println("Hello World");
}
}
I got this message:
我收到了这条消息:
Error:scalac: Scala compiler JARs not found (module 'scala02'):
E:\.ivy2\cache\org.scala-lang\scala-library\jars\scala-library-2.11.8.jar,
E:\.ivy2\cache\org.scala-lang\scala-compiler\jars\scala-compiler-2.11.8.jar,
E:\.ivy2\cache\org.scala-lang\scala-reflect\jars\scala-reflect-2.11.8.jar
I checked the Project Structure and checked the modules. Modules are located here:
我检查了项目结构并检查了模块。模块位于此处:
C:/Users/asus1/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.8.jar
How Can I change E: to C:/Users/asus1/ ?
Do I need to move all to E: ?
如何将 E: 更改为 C:/Users/asus1/ ?
我需要全部移到 E: 吗?
How people manage when the project and the jar are in different location ?
当项目和 jar 位于不同位置时,人们如何管理?
It seems a big bug of IntellJ ...?
这似乎是IntellJ的一个大错误......?
采纳答案by Orar
SOLVED as Follow:
解决如下:
In project settings, you need to manually add:
在项目设置中,需要手动添加:
- JDK Folder
Module and dependencies to JDK AND Scala JAR
In library, Add MANUALLY the JAR of Scala (IntelliJ does not add those JAR. it creates compile issues).
in Global library, check the JAR of scala are same.
- JDK文件夹
JDK 和 Scala JAR 的模块和依赖项
在库中,手动添加 Scala 的 JAR(IntelliJ 不添加那些 JAR。它会产生编译问题)。
在全局库中,检查 Scala 的 JAR 是否相同。
There is an option to see the DEBUG in verbose mode:
有一个选项可以在详细模式下查看调试:
https://intellij-support.jetbrains.com/hc/articles/207241085
https://intellij-support.jetbrains.com/hc/articles/207241085
This is very useful.
这是非常有用的。
回答by Orar
Please goto File > Settings (Ctrl+Alt+S, Windows)/Preferences (Mac) > Plugin Search for "scala". Uninstall Scala plugin.. Restart IDE. Reinstall it. Restart IDE and install the plugin. Everything works OK
请转到文件 > 设置(Ctrl+Alt+S,Windows)/首选项 (Mac) > 插件搜索“scala”。卸载 Scala 插件.. 重新启动 IDE。重新安装它。重新启动IDE并安装插件。一切正常
回答by Eron Wright
If your project is Gradle-based, one possibility is that the project is looking for Scala libraries in the .m2 cache that don't exist. To confirm, open "Project Structure...", go to "Libraries", and examine the list for "Gradle: org.scala-lang:..." that contain errors related to missing files.
如果您的项目是基于 Gradle 的,一种可能性是该项目正在 .m2 缓存中寻找不存在的 Scala 库。要确认,请打开“项目结构...”,转到“库”,然后检查包含与丢失文件相关的错误的“Gradle: org.scala-lang:...”列表。
If this is the issue, simply re-import the project from scratch.
如果这是问题所在,只需从头开始重新导入项目。
回答by Varsha
In IntelliJ, ensure that the external libraries are present. If already present, open library settings and check the path to the jars is not in red. If in red, correct the path to the jars
在 IntelliJ 中,确保存在外部库。如果已经存在,请打开库设置并检查 jar 的路径是否为红色。如果是红色,请更正罐子的路径

