【问题标题】:Gatling Error: Could not find or load main class EngineGatling 错误:无法找到或加载主类引擎
【发布时间】:2020-01-29 20:43:53
【问题描述】:

我安装了最新的IntelliJ idea,最新的maven 3.6.3Java 1.8,设置了JAVA_HOME / JRE_HOME env变量。然后使用mvn archetype:generate -Dfilter=gatling 生成一个 Gatling 项目。总之,我遵循了here 的指令。我也为 IntelliJ idea 安装了 Scala 插件。当我尝试通过右键单击 Engine 类来运行 Gatling 引擎时, 我得到以下错误。有人可以告诉我这里发生了什么吗?我在网上尝试了所有建议,但到目前为止没有运气。谢谢

"C:\Program Files (x86)\Java\jdk1.8.0_221\bin\java.exe".....

Error: Could not find or load main class Engine

Process finished with exit code 1 

这是我的 POM 文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany.gatling</groupId>
  <artifactId>pert-tests</artifactId>
  <version>1.0-SNAPSHOT</version>

  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <encoding>UTF-8</encoding>

    <gatling.version>3.2.1</gatling.version>
    <gatling-maven-plugin.version>3.0.3</gatling-maven-plugin.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>io.gatling.highcharts</groupId>
      <artifactId>gatling-charts-highcharts</artifactId>
      <version>${gatling.version}</version>
    </dependency>
    <dependency>
      <groupId>io.gatling</groupId>
      <artifactId>gatling-app</artifactId>
      <version>${gatling.version}</version>
    </dependency>
    <dependency>
      <groupId>io.gatling</groupId>
      <artifactId>gatling-recorder</artifactId>
      <version>${gatling.version}</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>io.gatling</groupId>
        <artifactId>gatling-maven-plugin</artifactId>
        <version>${gatling-maven-plugin.version}</version>
      </plugin>
    </plugins>
  </build>
</project>

【问题讨论】:

    标签: scala intellij-idea performance-testing gatling scala-gatling


    【解决方案1】:

    David Montaño... 手动将 src/test/scala 标记为测试源根目录后,我得到 Rasika 提到的“错误:(11, 18) 非法循环继承”

    我刚刚发现 scala 2.13.1 与 gatling 不兼容。我从全局库列表中删除了 scala 2.13.1 并添加了 scala 2.12.10。现在测试工作正常。以下是步骤

    1. 在 IntelliJ 中右键单击项目文件夹并选择“打开模块设置”

    2. 在“平台设置”下选择“全局库”

    3. 在这里,删除 scala-sdk-2.13.1 并添加 scala-sdk-2.12.10

    4. 重建模块

    【讨论】:

    • 一直在与 Gatling 断断续续地解决这个问题......这个降级到 2.12 的解决方案终于奏效了。谢谢!
    【解决方案2】:

    当我手动将 src/test/scala 标记为 Test Sources Root 并重建项目时,它对我有用。

    Mark as Test Sources Root

    它应该被 IntelliJ 自动拾取,但事实并非如此。

    【讨论】:

    • 感谢您的回复,仍然是同样的问题@David Montaño,解决方案编译得很好,但是当我查看解决方案文件夹时,我找不到任何包含已编译二进制文件的 bin 文件夹,可以是这个原因吗?
    • 我尝试在项目设置中将 scala SDK 2.13.1 添加到全局库,现在我收到编译错误错误:(11, 18) 涉及特征 Iterable Gatling.fromMap(props.build) 的非法循环继承)
    【解决方案3】:

    两者并列: 将 src/test/scala 标记为 Test Sources Root 并重建项目。

    标记为测试源根 和 在“平台设置”下选择“全局库”

    在这里,删除 scala-sdk-2.13.1 并添加 scala-sdk-2.12.10

    然后工作。

    【讨论】:

      猜你喜欢
      • 2016-06-12
      • 2016-03-16
      • 2016-01-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多