无法在Intellij中运行Scala文件 [英] Cannot run Scala file in Intellij

查看:186
本文介绍了无法在Intellij中运行Scala文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Intellij IDEA 14.4社区版中设立了一个加工项目。我安装了Scala插件,项目配置似乎是正确的(因为我没有看到并且内联错误和编译工作正常)。但是我在一些教程中有红色,你也可以通过右键单击它并选择运行或调试来运行当前文件。我没有看到这些选项,我无法理解原因:

I have set up a gatling project in Intellij IDEA 14.4 community edition. I have the Scala plugin installed and the project configuration seems to be correct (since I do not see and inline errors and compile works fine). However I have red in some tutorials that you can also run the current file by right clicking on it and choosing run or debug. I do not see these options and I cannot figure why:

我尝试过无效缓存/重启,但这也无效......

I have tried Invalidate Caches / Restart but that did not work either...

编辑:

我应该提到我没有使用scala的经验。我想要做的是实际上从Intellij运行个人 gatling 模拟因为它更方便我也可以调试它们。我所拥有的大多数代码都基于示例,但实际上我不知道我在做什么。所以重新制定,假设我有以下模拟文件 PingSimulation.scala 。我应该在哪里添加 main()函数才能在Intellij中单独运行文件?

I should have mentioned I have no experience with scala. What I am trying to do is actually run individual gatling simulations from Intellij because it is more convenient and I can also debug them. Most of the code I have is based on examples but in reality I have no idea what I am doing. So to reformulate, let's say I have the following simulation file PingSimulation.scala. Where should I add the main() function to be able to run the file individually in Intellij?

package atlas

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._

class PingSimulation extends Simulation {
  object Ping {
    val ping = exec(http("Ping")
      .get("/ping")
    )
  }

  val httpConf = http.baseURL(Endpoints.testing_url)

  val scn = scenario("Ping").exec(Ping.ping)

  setUp(
    scn.inject(atOnceUsers(1)).protocols(httpConf)
  )
}


推荐答案

从截图中看,似乎没有什么可以在范围内运行。你需要一个对象扩展 App 或提供 def main 。类本身无法运行。

From your screenshot there doesn't seem to be anything to run in scope. You need to have either an object that extends App or provides a def main. A class itself cannot be run.

这篇关于无法在Intellij中运行Scala文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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