JMeter中使用Map方法报错

2022-06-14  本文已影响0人  circle_hyy

在IDEA调试好的代码,搬到JMeter的Beanshell里运行出错了:
ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval In file: inline evaluation of:
错误行的代码是:

Map<Character,Integer> codes = new HashMap<Character,Integer>();

原因:beanshell 中使用Map方法中不能指定数据类型,List也一样
需要改成

Map codes = new HashMap();

运行通过
结论:Beanshell中不要使用类似于Map<String,Object> map = new HashMap<>();,包括引用Java文件的时候,Java文件中也不能这样使用,否则JMeter会报错。

上一篇 下一篇

猜你喜欢

热点阅读