[英]IntelliJ IDEA: Cannot import SBT project
I'm completely new to development using Play or IntelliJ for that matter.就此而言,我对使用 Play 或 IntelliJ 进行开发是完全陌生的。 I've created a simple HelloWorld application using Activator, and this is an
sbt
project.我使用 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.11.png
In almost all tutorials I've been through online, I've seen people using an sbt
option on the import screen.在我浏览过的几乎所有在线教程中,我都看到有人在导入屏幕上使用
sbt
选项。 I've installed the SBT plugin as well, but that hasn't helped.我也安装了 SBT 插件,但这并没有帮助。 I've restarted IntelliJ several times to no avail.
我已经多次重新启动 IntelliJ 无济于事。
Where am I going wrong?我哪里错了? I'm running
13.1.4
with the SBT
plugin installed.我正在运行
SBT
13.1.4
。
I had this error when importing a new module from existing sources.从现有源导入新模块时出现此错误。
SBT
tab.SBT
选项卡。/your-project-folder
/your-project-folder
./activator
./activator
idea
.idea
。 It will generate IDEA project.File->Open..
project in IDEA.File->Open..
项目。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.在我的情况下,问题是由意外打开 IdeaProjects 目录引起的。 When you do this, it creates the .Idea folder in that directory, and populates it as a project.
执行此操作时,它会在该目录中创建 .Idea 文件夹,并将其作为项目填充。 This apparently also confuses the set import.
这显然也混淆了集合导入。
The solution is to remove the .Idea folder and open (not import) the directory again.解决方案是删除 .Idea 文件夹并再次打开(而不是导入)目录。
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.当我尝试将新的 Scala 项目 A 作为模块导入到现有的 IntelliJ 项目 B 时遇到了同样的错误。 I solved the problem by following step below:
我通过以下步骤解决了这个问题:
After a series of struggles, I must say something weird solved this problem – moving to IntelliJ IDEA Ultimate.经过一系列的挣扎,我必须说一些奇怪的东西解决了这个问题——转向 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.
它内置了 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 与它一起工作,但我没有成功。
Import the project导入项目
build.sbt
file in the right place, so that IntelliJ can find it as an SBT project.build.sbt
文件,以便 IntelliJ 可以找到它作为 SBT 项目。此问题已在 SBT 和 Scala 插件的最新更新中解决。
Make sure that your java path is correct ( IntelliJ can use other path than system defined )确保您的 java 路径正确( IntelliJ 可以使用系统定义之外的其他路径)
Preferences -> Build, Execution, Deployment -> sbt -> JVM - choose a correct JRE
Preferences -> Build, Execution, Deployment -> sbt -> JVM - 选择一个正确的 JRE
IntelliJ IDEA 2022.2.1 (Ultimate Edition)
scala plugin: 2022.2.12
sbt version: 1.7.1
The number of steps to make it work may vary.使其工作的步骤数量可能会有所不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.