intellij 2020.1 sbt mainRunner配置

问题描述 投票:0回答:1

我正在尝试遵循intructions来设置与sbt一起使用的intellij scala项目。但是,我找不到intellij 2020.1中描述的运行/配置。基于this post,我了解此配置方式已更改。但是,该文章描述了如何使旧项目正常工作。我要为新项目做什么?

复制步骤

  1. 使用已经用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.
  1. 将项目导入intellij 2020.1

  2. 现在呢?我在intellij 2020.1中找不到“使用模块的类路径”下拉框。

intellij-idea sbt
1个回答
0
投票

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,请尝试

  1. Run | Edit Configurations...
  2. 单击加号按钮+Add New Configuration
  3. 选择Application
  4. 给名字说WordCount
  5. Main Class下用main方法指定Scala类,例如,org.example.WordCount
  6. Working directory应该是项目的根
  7. Use classpath of module设置为mainRunner
  8. JRE应该为1.8或以上

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.