[英]Unable to make IntelliJ Idea 12 work with Scala compiler
I have installed Scala, sbt, eclipse and IntelliJ Idea 12. And also jdk, jre, etc. I'm able to run scala in Eclipse (Scala eclipse IDE) but I can't do it in Idea, even though I downloaded and installed scala plugin though Idea. 我已经安装了Scala,sbt,eclipse和IntelliJ Idea12。还安装了jdk,jre等。我可以在Eclipse(Scala eclipse IDE)中运行scala,但是即使在我下载并通过Idea安装了scala插件。 Here is what I'm having at File -> Setting
这是我在“ File -> Setting
and at a new project creation page 在新的项目创建页面上
How do I solve these issues? 我该如何解决这些问题?
whereis scala
scala: /usr/bin/scala /usr/bin/X11/scala /usr/share/scala
which scala
/usr/bin/scala
I know I'm repeating this at any possible occasion—but your life will be much easier if you have sbt generate your IDEA project instead of trying to set it up manually. 我知道我会在任何可能的情况下重复此操作-但是,如果您使用sbt生成IDEA项目,而不是尝试手动进行设置,那么您的工作将会变得更加轻松。 That will take care of configuring the modules correctly, so you are instantly ready to compile and run. 这样可以正确配置模块,因此您可以立即进行编译和运行。
Here is a blog entry that might help. 这是一个可能有帮助的博客条目 。 The section "How can I integrate libraries installed by SBT to IDEA?" “如何将SBT安装的库集成到IDEA中”部分。 tells you how to generate the project files. 告诉您如何生成项目文件。
Basically you need to create—starting from the root directory of your project—the file project/plugins.sbt
with the following content: 基本上,您需要从项目的根目录开始创建文件project/plugins.sbt
,其内容如下:
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.4.0")
(you can also do that in the file ~/.sbt/plugins/build.sbt
instead, that way you have the plugin available for any of your projects) (您也可以在~/.sbt/plugins/build.sbt
文件中执行此操作,这样您就可以将插件用于任何项目)
Then you run sbt gen-idea
, and afterwards you can open the project directly from IDEA through File -> Open Project (and pointing to the project's root directory). 然后运行sbt gen-idea
,然后可以通过文件->打开项目(并指向项目的根目录)直接从IDEA中打开项目。
You could also generate your IDEA project with Gradle, which handles Scala+IDEA combination very well. 您还可以使用Gradle生成IDEA项目,该项目可以很好地处理Scala + IDEA组合。 Here's a minimal build.gradle
script to do this: 这是执行此操作的最小build.gradle
脚本:
apply plugin: 'scala'
apply plugin: 'idea'
repositories {
mavenCentral()
}
dependencies {
compile 'org.scala-lang:scala-library:2.10.1'
}
Just create a directory for your project, put build.gradle
inside it, create src/main/scala
subdirectory, then install Gradle and run gradle idea
inside your project's directory. 只需为您的项目创建一个目录,将build.gradle
放入其中,创建src/main/scala
子目录,然后安装Gradle并在项目目录中运行gradle idea
。 That should generate nicely configured IDEA project. 那应该会生成配置良好的IDEA项目。 With this method you don't even need to install Scala. 使用这种方法,您甚至不需要安装Scala。
What exactly your problem is? 你到底是什么问题? I don't see anything on your screens which prevents you from using Scala in IDEA. 我的屏幕上看不到任何东西,这使您无法在IDEA中使用Scala。 Just select "Set Scala Home" radiobutton in "New project" dialog and then select your Scala installation path (I guess it will be /usr/share/scala). 只需在“新建项目”对话框中选择“设置Scala主页”单选按钮,然后选择您的Scala安装路径(我想它将是/ usr / share / scala)。 IDEA then will automatically create library and compiler libraries and add Scala facet to your project. 然后,IDEA将自动创建库和编译器库,并将Scala facet添加到您的项目中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.