如何为 Scala 2.10 设置 Intellij
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14817388/
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 to setup Intellij for Scala 2.10
提问by learner
First I installed macports
Then I installed Scala and Play through macports: To make sure installation works I run a "hello world" on eclipse. It works!
But since my objective is to use Intellij, I try to follow the instructions at http://confluence.jetbrains.com/display/SCA/Getting+Started+with+IntelliJ+IDEA+Scala+Plugin
On step 3 of the instructions (section
Creating a Project), underuse scala distribution, I am not sure what to type. Will someone please tell me what to type? I am using mac os x mountain lion. I don't know the path to my scala installation.
首先我安装了macports
然后我通过 macports 安装了 Scala 和 Play:为了确保安装有效,我在 eclipse 上运行了一个“hello world”。有用!
但由于我的目标是使用 Intellij,我尝试按照http://confluence.jetbrains.com/display/SCA/Getting+Started+with+IntelliJ+IDEA+Scala+Plugin 上的说明进行操作
在说明(部分
Creating a Project)的第 3 步中,在 下use scala distribution,我不确定要键入什么。有人会告诉我要输入什么吗?我正在使用 mac os x 山狮。我不知道我的 Scala 安装路径。
I appreciate the help. I have already looked at Intellij Idea setup for Scala, clarification needed. No help there. My Intellij version is 12.0.3and my scala install is 2.10.
我很感激你的帮助。我已经看过Scala 的 Intellij Idea 设置,需要澄清。没有帮助。我的 Intellij 版本是12.0.3,我的 Scala 安装是2.10.
采纳答案by Brian Smith
I don't know OSX but presumably you can open a terminal, type ls -l `which scala`into it, and get the path to the scala executable.
我不知道 OSX,但大概你可以打开一个终端,输入ls -l `which scala`它,然后获取 scala 可执行文件的路径。
You can then enter that path, without the /bin/scalaon the end, into the intellij dialogue.
然后,您可以/bin/scala在没有结尾的情况下输入该路径,进入智能对话。
回答by José González
Just for clarification: you can install scalain Mac OS X using Homebrewas @JasonG mentions:
只是为了澄清:您可以使用Homebrew在 Mac OS X 中安装scala,如@JasonG 所述:
$ brew install scala --with-docs
In that case, the selected solution won't work, as IntelliJ will still complain. Any way, as stated in the caveats of the formula, you will have a directory specially crafted for IntelliJ integration:
在这种情况下,所选的解决方案将不起作用,因为 IntelliJ 仍会抱怨。无论如何,如公式的注意事项中所述,您将拥有一个专为 IntelliJ 集成设计的目录:
==> Caveats To use with IntelliJ, set the Scala home to: /usr/local/opt/scala/idea
==> 注意事项要与 IntelliJ 一起使用,请将 Scala 主目录设置为:/usr/local/opt/scala/idea
Using this directory will make IntelliJ happy.
使用这个目录会让 IntelliJ 开心。
UPDATE for IntelliJ IDEA 13.x users: This doesn't seem to be needed any more. Just use SBT based projects, and everything will be downloaded and configured automatically (Scala compiler and libraries)
IntelliJ IDEA 13.x 用户的更新:这似乎不再需要了。只需使用基于 SBT 的项目,一切都会自动下载和配置(Scala 编译器和库)
回答by Randall Schulz
You're much better served by letting existing tools do this sort of thing for you.
让现有工具为您做这种事情会更好地为您服务。
Define your project using SBT. Use PaulP's (Paul Phillips) SBT launcher and the sbt-ideaplug-in that provides automatic generation of IDEA project and module files.
使用 SBT 定义您的项目。使用 PaulP (Paul Phillips) SBT 启动器和sbt-idea提供自动生成 IDEA 项目和模块文件的插件。
See my previous answerfor some details
有关详细信息,请参阅我之前的答案
回答by JasonG
I actually downloaded the scala and scala docs from typesafe, unzipped them in a folder as per the instructions, and then pointed intellij at that. Use the sbt plugin as well - it makes life much better.
我实际上从 typesafe 下载了 scala 和 scala 文档,按照说明将它们解压缩到一个文件夹中,然后将 intellij 指向那个。也可以使用 sbt 插件 - 它让生活变得更好。
Alternatively you can use brew to install scala with docs:
或者,您可以使用 brew 安装带有文档的 scala:
$ brew install scala --with-docs
2.9.2 instructions here should work. http://scalacookbook.blogspot.ca/2012/09/scala-for-intellij.html
2.9.2 这里的说明应该可以工作。 http://scalacookbook.blogspot.ca/2012/09/scala-for-intellij.html
As a third option, you can just let intellij download scala for you. If it's not found, there is a download button you can hit. I'm not sure if it gets the docs though.
作为第三种选择,您可以让 Intellij 为您下载 scala。如果没有找到,您可以点击下载按钮。我不确定它是否得到了文档。
回答by t3hnar
- find and install scala plugin in "Preference" -> "Plugins" -> "Browse repositories" -> "Scala"
- open project and
- open"Project Structure"
- open "Facets"
- press "Add" / "Plus icon"
- select "Scala"
- 在“首选项”->“插件”->“浏览存储库”->“Scala”中找到并安装Scala插件
- 打开项目和
- 打开“项目结构”
- 打开“面”
- 按“添加”/“加号图标”
- 选择“斯卡拉”
Then you can select scala version and setup compiler
然后你可以选择scala版本并设置编译器

