首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven Gatling 3.0.2 - NoSuchMethodError

Maven Gatling 3.0.2 - NoSuchMethodError
EN

Stack Overflow用户
提问于 2019-05-08 19:32:24
回答 2查看 979关注 0票数 0

当我运行"mvn :test -Dgatling.simulationClass=package.SimpleSim“时,我得到以下错误:

代码语言:javascript
复制
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at io.gatling.mojo.MainWithArgsInFile.runMain(MainWithArgsInFile.java:50)
    at io.gatling.mojo.MainWithArgsInFile.main(MainWithArgsInFile.java:33)
Caused by: java.lang.NoSuchMethodError: scala.Product.$init$(Lscala/Product;)V
    at io.gatling.core.cli.CommandLineConstant.<init>(CommandLineConstant.scala:19)
    at io.gatling.app.cli.CommandLineConstants$.<init>(CommandLineConstants.scala:22)
    at io.gatling.app.cli.CommandLineConstants$.<clinit>(CommandLineConstants.scala)
    at io.gatling.app.cli.ArgsParser$$anon$1.<init>(ArgsParser.scala:30)
    at io.gatling.app.cli.ArgsParser.<init>(ArgsParser.scala:28)
    at io.gatling.app.Gatling$.fromArgs(Gatling.scala:46)
    at io.gatling.app.Gatling$.main(Gatling.scala:39)
    at io.gatling.app.Gatling.main(Gatling.scala)

我试着移除许多依赖项,只剩下Gatling高级图表和Gatling插件。它仍然会抛出同样的错误。

有趣的是,我从一个工作的项目中复制了许多代码,并且该项目现在仍在正常运行。

我不知道为什么这个新项目会发生这种情况.

pom:

代码语言:javascript
复制
  <parent>
    <artifactId>abc-pom</artifactId>
    <groupId>com.abc.def</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <gatling.version>3.0.3</gatling.version>
    <gatling-plugin.version>3.0.2</gatling-plugin.version>
  </properties>

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

  <build>
    <sourceDirectory>src/main</sourceDirectory>
    <testSourceDirectory>src/test</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>io.gatling</groupId>
        <artifactId>gatling-maven-plugin</artifactId>
        <version>${gatling-plugin.version}</version>
        <executions>
          <execution>
            <phase>integration-test</phase> 
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <configFolder>${project.basedir}/src/test/resources/gatling_conf</configFolder>
              <runMultipleSimulations>true</runMultipleSimulations>
              <includes>
                <simulationClass>package.SimpleSim</simulationClass>
              </includes>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

剧本:

代码语言:javascript
复制
package package.scalability_test

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

class SimpleSim extends Simulation {
    val httpProtocolBuilder = http.baseUrl("http://www.google.com")
    val scenarioBuilder = scenario("Get").exec(http("Get_Request")
        .get("/"))

    setUp(
        scenarioBuilder.inject(constantUsersPerSec(1) during(60 seconds))
    ).protocols(httpProtocolBuilder)
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-05-08 21:09:53

这个问题实际上是由于<parent></parent>标签造成的。这是一个大型项目中的一个项目。不知何故,继承父pom会引起一些冲突,从而导致这一问题。

我的解决方案是删除<parent>标记。但是,正确的解决方案可能是实际找出哪种依赖导致冲突。

票数 0
EN

Stack Overflow用户

发布于 2021-02-23 07:38:05

首先检查类路径mvn dependency:tree中的所有Scala版本,然后用兼容的Scala版本覆盖Gatling版本。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56047831

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档