scala IntelliJ IDEA:无法导入 SBT 项目

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

IntelliJ IDEA: Cannot import SBT project

scalaintellij-ideasbtintellij-plugin

提问by Ashesh

I'm completely new to development using Play or IntelliJ for that matter. I've created a simple HelloWorld application using Activator, and this is an sbtproject.

我对使用 Play 或 IntelliJ 的开发完全陌生。我已经使用 Activator 创建了一个简单的 HelloWorld 应用程序,这是一个sbt项目。

I've been trying to import this to IntelliJ and this is the screen I'm stuck at: https://www.dropbox.com/s/we1a4a3184sojvb/Screenshot%202014-07-24%2016.57.11.png

我一直在尝试将其导入 IntelliJ,这是我卡在的屏幕:https: //www.dropbox.com/s/we1a4a3184sojvb/Screenshot%202014-07-24%2016.57.1​​1.png

In almost all tutorials I've been through online, I've seen people using an sbtoption on the import screen. I've installed the SBT plugin as well, but that hasn't helped. I've restarted IntelliJ several times to no avail.

在我浏览过的几乎所有在线教程中,我都看到有人sbt在导入屏幕上使用一个选项。我也安装了 SBT 插件,但这并没有帮助。我已经多次重新启动 IntelliJ 无济于事。

Where am I going wrong? I'm running 13.1.4with the SBTplugin installed.

我哪里错了?我运行13.1.4SBT安装的插件。

采纳答案by Ashesh

After a series of struggles, I must say something weird solved this problem – moving to IntelliJ IDEA Ultimate. That has built in Play application support and can run/debug/test the application out of the box, which is very handy.

经过一系列的挣扎,我必须说一些奇怪的东西解决了这个问题——转向 IntelliJ IDEA Ultimate。它内置了 Play 应用程序支持,可以开箱即用地运行/调试/测试应用程序,非常方便。

All I can say after this experience was that JetBrains wants you to upgrade to Ultimate if you want things to work right out of the box.

在这次经历之后,我只能说 JetBrains 希望您升级到 Ultimate,如果您希望事情开箱即用。

I'm sure there are ways to get this working with CE also, but I wasn't successful with that.

我相信也有办法让 CE 与它一起工作,但我没有成功。

回答by Zoltán

I had this error when importing a new module from existing sources.

从现有源导入新模块时出现此错误。

  • On the right-hand side of your IntelliJ window, you will see a list of vertical tabs, open the SBTtab.
  • Select the module that's causing trouble, right click on it, select "Detach external project"
  • Try to import the module again.
  • 在 IntelliJ 窗口的右侧,您将看到一个垂直选项卡列表,打开该SBT选项卡。
  • 选择引起问题的模块,右键单击它,选择“分离外部项目”
  • 再次尝试导入模块。

回答by red1ynx

  1. Move to /your-project-folder
  2. Run ./activator
  3. Type idea. It will generate IDEA project.
  4. Open (not import) File->Open..project in IDEA.
  1. 搬去 /your-project-folder
  2. ./activator
  3. 键入idea。它将生成 IDEA 项目。
  4. File->Open..在 IDEA 中打开(不是导入)项目。

回答by sma

I encountered the same error when I was trying to import a new scala project A to an existing IntelliJ project B as a module. I solved the problem by following step below:

我在尝试将新的 Scala 项目 A 作为模块导入到现有的 IntelliJ 项目 B 时遇到了同样的错误。我通过以下步骤解决了这个问题:

  1. Go to your folder of project B. Open file .idea/sbt.xml.
  2. Deleting the entry which includes the path of project A.
  1. 转到项目 B 的文件夹。打开文件 .idea/sbt.xml。
  2. 删除包含项目A路径的条目。

回答by Chris Travers

I had a similar problem which came from a different place than the other solutions here so adding it in case it occurs for others.

我有一个类似的问题,它来自与这里的其他解决方案不同的地方,所以添加它以防其他人发生。

In my case the problem was caused by accidentally opening the IdeaProjects directory. When you do this, it creates the .Idea folder in that directory, and populates it as a project. This apparently also confuses the set import.

在我的情况下,问题是由意外打开 IdeaProjects 目录引起的。执行此操作时,它会在该目录中创建 .Idea 文件夹,并将其作为项目填充。这显然也混淆了集合导入。

The solution is to remove the .Idea folder and open (not import) the directory again.

解决方案是删除 .Idea 文件夹并再次打开(而不是导入)目录。

回答by DanielDiSu

This issue is solved in the latest updates of the SBT and Scala plugins.

此问题已在 SBT 和 Scala 插件的最新更新中解决。

回答by Ryoichiro Oka

  1. Uninstall everything
  2. Reinstall IntelliJ
  3. Install the JetBrains official Scala plugin
  4. Import the project

    • Make sure that the project has a build.sbtfile in the right place, so that IntelliJ can find it as an SBT project.
    • This is about IntelliJ IDEA version 13.1.4.
  1. 卸载一切
  2. 重新安装 IntelliJ
  3. 安装JetBrains 官方 Scala 插件
  4. 导入项目

    • 确保该项目build.sbt在正确的位置有一个文件,以便 IntelliJ 可以将其作为 SBT 项目找到。
    • 这是关于 IntelliJ IDEA 版本 13.1.4。