intellij 2020.1 sbt mainRunner配置 [英] intellij 2020.1 sbt mainRunner configuration

查看:255
本文介绍了intellij 2020.1 sbt mainRunner配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to follow the intructions for setting up intellij scala project to work with sbt. However, I am not finding the run/configuration described in intellij 2020.1. Based on this post I understand that the way this is configured has changed. However, that post describes how to make old project work. What do I do for new projects?

复制步骤

  1. 使用已经用mainRunner配置的idea.sbt创建一个不错的sbt项目

sbt new tillrohrmann/flink-project.g8

这包括idea.sbt

this includes 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,内容为:

It also comes with a README.md that says:

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

  1. Import project into intellij 2020.1

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

Now what? I cannot find a "Use classpath of module" dropbox in intellij 2020.1.

推荐答案

IntelliJ的Use classpath of module对应于sbt的子项目的类路径.要使用mainRunner项目的类路径创建Run Configuration,请尝试

IntelliJ's Use classpath of module corresponds to the classpath of sbt's sub-project. To create a Run Configuration using the classpath of mainRunner project try

  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或更高
  1. Run | Edit Configurations...
  2. Click the plus button + to Add New Configuration
  3. Select Application
  4. Give it a name say WordCount
  5. Under Main Class specify Scala class with main method, say, org.example.WordCount
  6. Working directory should be the root of the project
  7. Set Use classpath of module to mainRunner
  8. JRE should be 1.8 or above

注意,作为使用mainRunner项目的替代方法,您也可以使用根项目,但选中复选框Include dependencies with "Provided" scope.

Note as an alternative to using mainRunner project you could also use root project but select the checkbox Include dependencies with "Provided" scope.

这篇关于intellij 2020.1 sbt mainRunner配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆