Scala 的 Intellij Idea 设置,需要澄清

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13716420/
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-10-22 04:46:22  来源:igfitidea点击:

Intellij Idea setup for Scala, clarification needed

scalaintellij-idea

提问by James Raitsev

Using IntelliJIdea 12, i downloaded the Scala plugin and created a HelloWorld application.

使用 IntelliJIdea 12,我下载了 Scala 插件并创建了一个 HelloWorld 应用程序。

The following import seems odd. Why does IDEA not recognize this to be a Scala Application? Is my setup incomplete?

以下导入似乎很奇怪。为什么 IDEA 不承认这是一个 Scala 应用程序?我的设置不完整吗?

enter image description here

在此处输入图片说明

I checked to see where does my compiler points to and got this. Don't really see a way to navigate IDEA to my scala installation.

我检查了我的编译器指向哪里并得到了这个。真的没有看到将 IDEA 导航到我的 Scala 安装的方法。

Please advise.

请指教。

enter image description here

在此处输入图片说明

采纳答案by CrazyCoder

When creating a new Scala project from the wizard IDEA can download and configure everything for you:

从向导创建新的 Scala 项目时,IDEA 可以为您下载和配置所有内容:

New Scala Project

新的 Scala 项目

Settings can be changed later in the Scala Facet:

稍后可以在Scala Facet 中更改设置:

facet

刻面

and in Compiler:

并在编译器中

compiler

编译器

Libraries configuration:

库配置:

compiler

编译器

scala

斯卡拉

Code and imports completion is available from the Scalalibrary:

代码和导入完成可从Scala库获得:

completion

完成

回答by sourcedelica

You need to add Scala as a framework for your project.

您需要将 Scala 添加为您的项目的框架。

To do this, right click on the top level directory in your project, choose "Add Framework Support..." and select Scala. Then Scala will be added as a "Facet" of your project.

为此,请右键单击项目中的顶级目录,选择“添加框架支持...”并选择 Scala。然后 Scala 将被添加为您项目的“方面”。

Here is a good page with more info:

这是一个包含更多信息的好页面:

回答by Plasty Grove

I got around this by downloading the Scala library from scala-lang.org, unzipping it and then pointing the project to it. It worked fine after that. But of course, I'm an eclipse guy so perhaps someone else might be able to give you a better automated (?) solution. Here's what my project looks like in Module Settings -> Libraries:

我通过从 scala-lang.org 下载 Scala 库,解压缩它,然后将项目指向它来解决这个问题。在那之后它工作得很好。但是,当然,我是一个 eclipse 人,所以也许其他人可以为您提供更好的自动化(?)解决方案。这是我的项目在模块设置 -> 库中的样子:

enter image description here

在此处输入图片说明