我正在尝试遵循指示 https://github.com/JetBrains/intellij-scala/wiki/%5BSBT%5D-How-to-use-provided-libraries-in-run-configurations用于设置 intellij scala 项目以与 sbt 一起使用。但是,我没有找到 intellij 2020.1 中描述的运行/配置。基于这个帖子 https://stackoverflow.com/questions/61246546/sbt-run-debug-configuration-broken-showing-unknown-after-upgrading-intellij-to-2据我所知,配置方式已经改变。然而,那篇文章描述了如何使旧项目发挥作用。我该为新项目做什么?
重现步骤
- 使用已经配置了 mainRunner 的 idea.sbt 创建漂亮的 sbt 项目
sbt new tillrohrmann/flink-project.g8
这包括 idea.sbt
lazy val mainRunner = project.in(file("mainRunner")).dependsOn(RootProject(file("."))).settings(
// we set all provided dependencies to none, so that they are included in the classpath of mainRunner
libraryDependencies := (libraryDependencies in RootProject(file("."))).value.map{
module => module.configurations match {
case Some("provided") => module.withConfigurations(None)
case _ => module
}
}
)
它还附带一个 README.md,内容如下:
You can also run your application from within IntelliJ: select the classpath of the 'mainRunner' module in the run/debug configurations.
Simply open 'Run -> Edit configurations...' and then select 'mainRunner' from the "Use classpath of module" dropbox.
将项目导入intellij 2020.1
怎么办?我在 intellij 2020.1 中找不到“使用模块的类路径”保管箱。
IntelliJ 的Use classpath of module
对应sbt的子项目的classpath。创建一个Run Configuration
使用类路径mainRunner
项目尝试
Run | Edit Configurations...
- 单击加号按钮
+
to Add New Configuration
- Select
Application
- 给它起个名字说
WordCount
- Under
Main Class
指定 Scala 类main
方法,说,org.example.WordCount
-
Working directory
应该是项目的根
- Set
Use classpath of module
to mainRunner
- JRE 应为 1.8 或更高版本
注意作为使用的替代方法mainRunner
项目,您也可以使用根项目,但选中复选框Include dependencies with "Provided" scope
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)