jars could not be resolved for apache jmter 2.13 w

2020-02-12 09:46发布

I am trying to run jmeter script using java code. I already made one jmx. Iam using jmeter 2.13 when I tried to run the code it is showing me this error.

Failed to execute goal on project JmeterJson: Could not resolve dependencies for project JmeterJson:JmeterJson:war:0.0.1-SNAPSHOT: The following artifacts could not be resolved: commons-math3:commons-math3:jar:3.4.1, commons-pool2:commons-pool2:jar:2.3: Could not find artifact commons-math3:commons-math3:jar:3.4.1 in central (https://repo.maven.apache.org/maven2) -> [Help 1] [ERROR]

My pom.xml

<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>JmeterJson</groupId>
  <artifactId>JmeterJson</artifactId>  
  <version>0.0.1-SNAPSHOT</version>   
  <packaging>war</packaging>  
  <properties>    
    <spring.version>4.0.0.RELEASE</spring.version>     
    <jdk.version>1.8</jdk.version> 
    <jackson.version>1.9.10</jackson.version>   
  </properties>  

  <dependencies>    
    <dependency>    
      <groupId>org.apache.jmeter</groupId> 
      <artifactId>ApacheJMeter_core</artifactId> 
      <version>2.13</version>   
    </dependency>
    <dependency>      
      <groupId>org.springframework</groupId>     
      <artifactId>spring-core</artifactId>     
      <version>${spring.version}</version>   
    </dependency>   
    <dependency> 
      <groupId>org.apache.jmeter</groupId>  
      <artifactId>ApacheJMeter_http</artifactId>
      <version>2.13</version>   
        <exclusions>
          <exclusion>
            <artifactId>commons-math3</artifactId>
            <groupId>commons-math3</groupId>
          </exclusion>
          <exclusion>
                  <artifactId>commons-pool2</artifactId>
                  <groupId>commons-pool2</groupId>
                </exclusion>   
             </exclusions> 
              </dependency>

                 <dependency>      
            <groupId>org.springframework</groupId>     
             <artifactId>spring-web</artifactId>      
             <version>${spring.version}</version>    
             </dependency>  
                 <dependency>     
              <groupId>org.springframework</groupId>    
                <artifactId>spring-webmvc</artifactId>      
               <version>${spring.version}</version>    
              </dependency>  
                 <!-- Jackson JSON Mapper -->    
              <dependency>      
             <groupId>org.codehaus.jackson</groupId>    
          <artifactId>jackson-mapper-asl</artifactId>     
         <version>1.9.10</version>    
           </dependency>  

            <dependency>
           <groupId>com.fasterxml.jackson.core</groupId>
           <artifactId>jackson-databind</artifactId>
            <version>2.4.4</version>  
           </dependency>  
            </dependencies>   

                 <build>
                <sourceDirectory>src</sourceDirectory>
                <plugins>
                  <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.3</version>
                    <configuration>
                      <source>1.8</source>
                      <target>1.8</target>
                    </configuration>
                  </plugin>
                   <plugin>
                                <groupId>com.lazerycode.jmeter</groupId>
                                <artifactId>jmeter-maven-plugin</artifactId>
                                <version>1.10.1</version>
                                <executions>
                                    <execution>
                                        <id>jmeter-tests</id>
                                        <phase>verify</phase>
                                        <goals>
                                            <goal>jmeter</goal>
                                        </goals>
                                    </execution>
                                </executions>
                            </plugin>
                  <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.6</version>
                    <configuration>
                      <warSourceDirectory>WebContent</warSourceDirectory>
                      <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                  </plugin>
                </plugins>   
  </build> 
</project>

Before, when I didn't add jmeter jar, it was working fine.

1条回答
贼婆χ
2楼-- · 2020-02-12 10:16

Edit November 2017:

  • Last version 2.5.1 of JMeter Maven Plugin is now compatible with JMeter 3.3, so the most viable fix is to upgrade.

This is due to an issue in JMeter 2.13 pom which is fixed in nightly build:

Add this into JMeter dependency:

<exclusions>
  <exclusion>
    <artifactId>commons-math3</artifactId>
    <groupId>commons-math3</groupId>
  </exclusion>
  <exclusion>
    <artifactId>commons-pool2</artifactId>
    <groupId>commons-pool2</groupId>
  </exclusion>
</exclusions>

And add:

<dependency>
   <groupId>org.apache.commons</groupId>
   <artifactId>commons-math3</artifactId>
   <version>3.4.1</version>
</dependency>
<dependency>
   <groupId>org.apache.commons</groupId>
   <artifactId>commons-pool2</artifactId>
   <version>2.3</version>
</dependency>
查看更多
登录 后发表回答