我正在尝试通过 gradle 运行 gatling 任务。我专门设置了我的 scala 源代码集,在运行 gatlingRun 之前运行 compileScala,但我不断收到错误消息:
java.lang.ClassNotFoundException: BasicSimulation
如何正确设置任务?
build.gradle
:
plugins {
id "com.github.lkishalmi.gatling" version "3.0.2"
}
repositories {
mavenCentral()
}
apply plugin: 'java'
apply plugin: 'scala'
sourceSets {
main {
scala {
srcDirs = ['src/gatling/simulations/']
}
}
}
dependencies {
compile "io.gatling:gatling-core:3.0.2"
compile "io.gatling:gatling-http:3.0.2"
compile 'io.gatling.highcharts:gatling-charts-highcharts:3.0.2'
compile 'org.scala-lang:scala-library:2.11.8'
}
gatling {
simulations = {
include "*.scala"
}
}
渐变语法:
gradlew compileScala gatlingRun -Dorg.gradle.java.home=C:\Users\saber.alex\Documents\jre1.8.0_91
错误:
> Task :gatlingRun
16:22:52.131 [main] INFO io.gatling.core.config.GatlingConfiguration$ - Gatling will try to use 'gatling.conf' as custom config file.
16:22:52.910 [GatlingSystem-akka.actor.default-dispatcher-2] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
16:22:54.045 [main] ERROR io.gatling.app.Gatling$ - Run crashed
java.lang.IllegalArgumentException: User defined Simulation class BasicSimulation could not be loaded
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:79)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$4(Selection.scala:84)
at scala.Option.orElse(Option.scala:289)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$3(Selection.scala:84)
at scala.Option.flatMap(Option.scala:171)
at io.gatling.app.Selection$Selector.singleSimulationFromConfig(Selection.scala:82)
at io.gatling.app.Selection$Selector.$anonfun$selection$1(Selection.scala:52)
at scala.Option.getOrElse(Option.scala:121)
at io.gatling.app.Selection$Selector.selection(Selection.scala:44)
at io.gatling.app.Selection$.apply(Selection.scala:36)
at io.gatling.app.Runner.run0(Runner.scala:74)
at io.gatling.app.Runner.run(Runner.scala:61)
at io.gatling.app.Gatling$.start(Gatling.scala:74)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:47)
at io.gatling.app.Gatling$.main(Gatling.scala:39)
at io.gatling.app.Gatling.main(Gatling.scala)
Caused by: java.lang.ClassNotFoundException: BasicSimulation
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$2(Selection.scala:70)
at scala.util.Try$.apply(Try.scala:209)
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:70)
... 15 common frames omitted
> Task :gatlingRun FAILED
3 actionable tasks: 3 executed
最佳答案
gatling 中存在与更改源目录相关的错误。 https://github.com/gatling/gatling/issues/3301
尝试使用默认目录进行模拟。它在 SBT 项目中对我有帮助。
关于java - 如何修复 : java. lang.ClassNotFoundException : BasicSimulation for gradle gatlingRun task?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57729523/