如何更改 Intellij 想法以使用 Scala 2.11 进行编译?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25653265/
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
How do I change intellij idea to compile with scala 2.11?
提问by Di Zou
I am using Intellij Idea 13.1.4. I have a scala sbt project. It is currently being compiled with Scala 2.10. I would like to change this to Scala 2.11. In my build.sbt, I have:
我正在使用 Intellij Idea 13.1.4。我有一个 scala sbt 项目。它目前正在用 Scala 2.10 编译。我想将其更改为 Scala 2.11。在我的 build.sbt 中,我有:
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-compiler" % "2.11.0",
...
)
When I build my project, it still builds as a Scala 2.10 project.
当我构建我的项目时,它仍然构建为 Scala 2.10 项目。
Also, under my Project Settings->Modules->Scala->Facet 'Scala'->Compiler library, Intellij still shows scala-compiler-bundle:2.10.2. There is no option for a 2.11.xbundle. How would I get an option for Scala 2.11.x?
此外,在 my 下Project Settings->Modules->Scala->Facet 'Scala'->Compiler library,Intellij 仍然显示scala-compiler-bundle:2.10.2. 没有2.11.x捆绑选项。我如何获得 Scala 2.11.x 的选项?
Thanks!
谢谢!
回答by NOTiFY
In IntelliJ 2016.x you upgrade Scala by
在 IntelliJ 2016.x 中,您可以通过以下方式升级 Scala
Ensure Scala Plugin up to date.
确保 Scala 插件是最新的。
Then by going to:
然后去:
File | Other Settings | Default Project Structure | Global Libraries
档案 | 其他设置 | 默认项目结构 | 全球图书馆
Click the +button at the top left hand side of the Window
单击+窗口左上角的按钮
Select Scala SDK
选择 Scala SDK
Choose the version you want to install.
选择要安装的版本。
回答by traceformula
I have had the same issue as you. I added scala version 2.11 in my build.sbt.
After that, I removed the default scala SDK by
我和你有同样的问题。我在我的build.sbt. 之后,我删除了默认的Scala SDK
- Go to
File > Other Settings > Default Project Structures > Platform Settings > Global Libraries - Remove
scala-sdk-2.10.6
- 去
File > Other Settings > Default Project Structures > Platform Settings > Global Libraries - 消除
scala-sdk-2.10.6
Hence, IntelliJ will pick up my project scala SDK (after I do sbt assembly)
因此,IntelliJ 将拿起我的项目 scala SDK(在我做之后sbt assembly)
回答by jrp
In .iml file, there is entry for scala sdk library as shown below:
在.iml文件中,有scala sdk库的入口,如下图:
<orderEntry type="library" name="scala-sdk-2.10.6" level="application" />
<orderEntry type="library" name="scala-sdk-2.11.8" level="application" />
comment or remove the scala sdk version entry that you dont want.
评论或删除您不想要的 scala sdk 版本条目。
回答by aya_cool
add this to your build.sbt file
将此添加到您的 build.sbt 文件中
scalaVersion='2.11.11'
scalaVersion='2.11.11'
回答by Javi12
You'll have to add first a new scala-compiler in File > Other Settings > Default Project Structure…
您必须首先在文件 > 其他设置 > 默认项目结构中添加一个新的 Scala 编译器...
In scala-compiler include:
在 Scala 编译器中包括:
<SCALA_HOME>/lib/scala-compiler.jar
<SCALA_HOME>/lib/scala-library.jar
<SCALA_HOME>/lib/scala-reflect.jar
Replace with your scala installation directory.
替换为您的 Scala 安装目录。
Go to File > Project Settings… and select the newly created compiler-library in "Compiler library". You may have to select Scala 2.11 in Language Level as well.
转到文件 > 项目设置...并在“编译器库”中选择新创建的编译器库。您可能还必须在语言级别中选择 Scala 2.11。

