【问题标题】:Getting "Cannot resolve symbol core" while writing Gatling script编写加特林脚本时出现“无法解析符号核心”
【发布时间】:2021-11-27 12:05:18
【问题描述】:

我正在尝试在 Intellij Idea 上创建一个 Gatling 负载测试脚本,而我正处于起步阶段。我用 Maven 创建了一个 Gatling 项目,但我无法导入 io.gatling.core 包。

您能帮我解决我的问题吗?提前致谢。

我的 pom.xml 文件:

<?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>io.gatling</groupId>
  <artifactId>gatling-core</artifactId>
  <version>3.5.1</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.5.1</gatling.version>
    <gatling-maven-plugin.version>3.1.1</gatling-maven-plugin.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>io.gatling.highcharts</groupId>
      <artifactId>gatling-charts-highcharts</artifactId>
      <version>3.5.1</version>
    </dependency>
    <dependency>
      <groupId>io.gatling</groupId>
      <artifactId>gatling-app</artifactId>
      <version>3.5.1</version>
    </dependency>
    <dependency>
      <groupId>io.gatling</groupId>
      <artifactId>gatling-recorder</artifactId>
      <version>3.5.1</version>
    </dependency>
    <dependency>
      <groupId>io.gatling</groupId>
      <artifactId>gatling-core</artifactId>
      <version>3.5.1</version>
    </dependency>
  </dependencies>

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

我想要达到的目标:

import io.gatling.core.scenario.Simulation
import io.gatling.core.Predef._
import io.gatling.http.Predef._

【问题讨论】:

  • 您的本地 maven 缓存中很可能有一个损坏的 gatling-core jar。您应该从本地 maven 缓存中删除 gatling-core-3.5.1.jar 并重新触发从 maven 获取的 deps。

标签: scala maven gatling


【解决方案1】:

或者您应该只使用${"ANY_PACKAGE".version} 之类的变量,或者从终端检查正确的版本。

【讨论】:

    【解决方案2】:

    加特林创造者在这里。

    真的,正如我在评论中所解释的,您的问题很可能是您的本地 maven 缓存中有损坏的 gatling-core-3.5.1.jar。只需从那里删除它并重新触发 maven 下载就可以了。

    希望对遇到此问题的人有所帮助。

    【讨论】:

      【解决方案3】:

      我使用 Gatling 3.5.1 将 pom.xml 更改为以下内容,现在可以使用:

      <?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.gokhan</groupId>
        <artifactId>Test</artifactId>
        <version>1.0</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.5.1</gatling.version>
          <gatling-maven-plugin.version>3.1.1</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>
          <testSourceDirectory>src/test/scala</testSourceDirectory>
          <plugins>
            <plugin>
              <groupId>io.gatling</groupId>
              <artifactId>gatling-maven-plugin</artifactId>
              <version>${gatling-maven-plugin.version}</version>
            </plugin>
          </plugins>
        </build>
      </project>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-08-18
        • 1970-01-01
        • 2022-11-16
        • 1970-01-01
        • 2016-12-19
        • 2012-06-29
        • 2018-11-11
        相关资源
        最近更新 更多