IntelliJ Idea 中的 Scala 模块 SDK
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4773784/
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
Module SDK for Scala in IntelliJ Idea
提问by Etam
How do you create Module SDK in Project Settings / Modules / Dependencies for Scala in IntelliJ Idea?
如何在 IntelliJ Idea 中为 Scala 的项目设置/模块/依赖项创建模块 SDK?
回答by Kevin Wright
I'm assuming you mean Project Structure-> Modules -> Dependencies
我假设您的意思是项目结构-> 模块 -> 依赖项
You can just click on the Add...button in that view. A "Module" here is simply a Jar file or directory containing classes.
您只需单击Add...该视图中的按钮即可。这里的“模块”只是一个包含类的 Jar 文件或目录。
You wouldn't normally do this though. A better approach is:
不过,您通常不会这样做。更好的方法是:
- Create the project using Maven and the maven-scala-plugin, then import it as a Maven project into IntelliJ
- 使用 Maven 和 maven-scala-plugin 创建项目,然后将其作为 Maven 项目导入 IntelliJ
or
或者
- Create the project using SBT, and use the SBT IDEA plugin to generate the IntelliJ project
- 使用SBT创建项目,并使用SBT IDEA插件生成IntelliJ项目
Either way, the correct dependencies will then be created for you.
无论哪种方式,都会为您创建正确的依赖项。
UPDATE
更新
Based on your comment, it looks as though your problem is that IntelliJ doesn't know where to find the Java SDK (this is nothing to do with modules, it just happens to appear in that window)
根据您的评论,您的问题似乎是 IntelliJ 不知道在哪里可以找到 Java SDK(这与模块无关,它恰好出现在该窗口中)
Under Project Structure -> Project, you'll see an option for "Project SDK" with the value "" highlighted in red.
在 Project Structure -> Project 下,您将看到“Project SDK”选项,其中值“”以红色突出显示。
Click the newbutton beside this, select "jsdk", and point it to the directory where you installed the Java SDK.
点击new旁边的按钮,选择“jsdk”,指向你安装Java SDK的目录。
Then all should be good.
那么一切都应该是好的。
回答by coderwithattitude
i had this same problem to solve it right-click on your project and click "Add framework support" then click add library and navigate to the lib folder in your Scala directory in your pc
我遇到了同样的问题来解决它右键单击您的项目并单击“添加框架支持”然后单击添加库并导航到您电脑中 Scala 目录中的 lib 文件夹
回答by toidiu
I spent some 2 hours trying to figure a similar issue. My files were complaining that there was no Scala SDK setup and to add it as a module dependency. However the scala dependency was not compiled so it was giving errors.
我花了大约 2 个小时试图找出类似的问题。我的文件抱怨没有 Scala SDK 设置并将其添加为模块依赖项。然而,scala 依赖没有被编译,所以它给出了错误。
The trick was to choose SBT as the model when importing the project and let IntelliJ add your dependencies.
诀窍是在导入项目时选择 SBT 作为模型,并让 IntelliJ 添加您的依赖项。
回答by aravindaM
Download and install Scala from Official web site. Create a new Scala SDK and point it to the scala installation path.(eg: C:\Program Files (x86)\scala ) Choose this SDK while creating the new project. Otherwise you can create the Scala SDK during the new project wizard as well.
从官方网站下载并安装 Scala 。创建一个新的 Scala SDK 并将其指向 Scala 安装路径。(例如: C:\Program Files (x86)\scala ) 在创建新项目时选择此 SDK。否则,您也可以在新项目向导期间创建 Scala SDK。
回答by Seif Tamallah
回答by Dozon Higgs
So, what that solved that for me was:
所以,对我来说解决这个问题的是:
- close intelliJ
- open the project folder and delete intelliJs folder that was added on import.
simply
rm -rf .idea(mac/linux etc.) - import the project again...
- 接近智能
- 打开项目文件夹并删除导入时添加的 intelliJs 文件夹。简单
rm -rf .idea(mac/linux 等) - 再次导入项目...


