简体   繁体   中英

Cannot run Scala file in Intellij

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...

EDIT:

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)
  )
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM