我正在尝试遵循intructions来设置与sbt一起使用的intellij scala项目。但是,我找不到intellij 2020.1中描述的运行/配置。基于this post,我了解此配置方式已更改。但是,该文章描述了如何使旧项目正常工作。我要为新项目做什么?
复制步骤
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's sub-project
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
}
}
)
使用Run Configuration
的类路径创建mainRunner
,请尝试
Run | Edit Configurations...
+
至Add New Configuration
Application
WordCount
Main Class
下用main
方法指定Scala类,例如,org.example.WordCount
Working directory
应该是项目的根Use classpath of module
设置为mainRunner