How do you create Module SDK in Project Settings / Modules / Dependencies for Scala in IntelliJ Id开发者_开发知识库ea?
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.
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
or
- Create the project using SBT, and use the SBT IDEA plugin to generate the IntelliJ project
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)
Under Project Structure -> Project, you'll see an option for "Project SDK" with the value "" highlighted in red.
Click the new
button beside this, select "jsdk", and point it to the directory where you installed the Java SDK.
Then all should be good.
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
right click on the project and click add framwork support
and select the Scala library :
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.
The trick was to choose SBT as the model when importing the project and let IntelliJ add your dependencies.
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...
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.
For MAC users:
With the latest IntelliJ IDEA 2020.2.2 (Community Edition) (Build #IC-202.7319.50, built on September 15, 2020), 2 things have to be done:
- Go to IntelliJ IDEA -> Preferences -> Plugins -> Scala
- Now, install scala using home-brew : brew install scala
Once these both are done, open a scala project and File -> Project Structure -> Global Libraries -> click on '+' -> Scala SDK -> select or download the sdk -> Add.
This worked for me.
I have a multi-module Gradle project. Most of them are Java and one is Scala. The project built successfully on the terminal, but IntelliJ complained missing SDK on the Scala code tabs.
The root cause might be that I opened this project before installing the Scala plugin. I restarted the IDE and clicked Reload All Gradle Projects
in the Gradle tab on the right-hand side. Then the problem was solved.
精彩评论