JMeter - 在类“java.nio.file.Paths"中找不到静态方法 get(java.lang.String) [英] JMeter - Static method get( java.lang.String ) not found in class'java.nio.file.Paths'
问题描述
我正在尝试创建一个 JMeter 负载测试.我需要测试以获取示例日志文件并更改其名称.我能找到的唯一方法是在 BeanShell 预处理器中复制文件,但出现以下错误:
I am trying to create a JMeter load test. I need the test to take a sample log file and change its name. The only way I could find to do this was to copy the file in a BeanShell Preprocessor but I am getting the following error:
ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: evalSourced file: inline evaluation of: ``import java.nio.file.StandardCopyOption; import java.io.IOException; import java . . . '' : Typed variable declaration : Error in method invocation: Static method get( java.lang.String ) not found in class'java.nio.file.Paths'
我使用的代码如下:
import java.nio.file.StandardCopyOption;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Path source = Paths.get(vars.get("filename");
String filename = "/Users/GX1/Desktop/jmeter/tmp/Device_"+vars.get("global_counter")+"_upload_"+vars.get("file_counter")+".csv.gz";
Path target = Paths.get(filename);
Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
vars.put("filename", filename);
filename、global_counter 和 file_counter 是 jmeter 变量.
filename, global_counter and file_counter are jmeter variables.
有谁知道我为什么会收到这个错误?beanshell 预处理器是否无法按照我尝试使用的方式工作?
Does anyone know why I am getting this error? Does the beanshell preprocessor not work in the way I am trying to use it?
推荐答案
我猜测是问题在于它没有填充 varargs 参数.试试:
My guess is that the problem is that it's not populating the varargs parameter. Try:
Path target = Paths.get(filename, new String[0]);
这篇关于JMeter - 在类“java.nio.file.Paths"中找不到静态方法 get(java.lang.String)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!