Unable to create Scala class on IntelliJ

2019-01-30 07:18发布

I'm just starting to learn Scala. I have installed the Scala plugin for IntelliJ, and created a new Scala project. But when I right-click on the src folder to make a new Scala class, there is no option to do so. Am I missing something?

14条回答
Summer. ? 凉城
2楼-- · 2019-01-30 07:54

Right click on your project, "Add Framework support" and choose Scala framework, then by right click on the packages you can create Scala Class.

查看更多
Luminary・发光体
3楼-- · 2019-01-30 07:54

Go to Src folder and choose Mark as Directory then choose the option called source root, that would fix your problem.

查看更多
家丑人穷心不美
4楼-- · 2019-01-30 08:01

add libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.50" in target -> built.sbt file this works for IntelliJ IDEA 2017

查看更多
别忘想泡老子
5楼-- · 2019-01-30 08:01

I experienced this behavior when the folder was not correctly marked as a source folder (blue folder symbol). If that is the case, simply right-click on the whole project and choose Open Module Settings where you can then mark the respective folder as source: Module settings where you may select src as Source folder

查看更多
放我归山
6楼-- · 2019-01-30 08:02

Intellij by default doesn't pick up the dependencies at times. You'll need to create a seperate sbt or maven project and then import it to Intellij.

If you want to create a Java Scala Mixin project you can follow this blog post. And then import it in Intellij.

Or if your just trying to learn Scala.

You can download this maven based Scala Starter Template and import it in intellij and then continuing working on it.

Note : You might have to specify the sources for the module in the

Project Structure -> Modules Tab

查看更多
一纸荒年 Trace。
7楼-- · 2019-01-30 08:03

You just need to select the 'Package' instead of 'Project' option from the drop-down menu just above your project name.

查看更多
登录 后发表回答