[英]Method info( java.util.HashMap ) not found in class'org.apache.log.Logger'
log.info(m.differenceValue(jsonElement1,jsonElement2));
calling function from beanshell. 从beanshell调用函数。 The code implemented in jar file. 该代码在jar文件中实现。
public static <K, V> Map<String,Object> differenceValue(JsonElement json1, JsonElement json2){
Gson g = new Gson();
Type mapType = new TypeToken<Map<String, Object>>(){}.getType();
Map<String,Object> firstMap = g.fromJson(json1, mapType);
Map<String, Object> secondMap = g.fromJson(json2, mapType);
return(mapDifference(firstMap,secondMap));
}
public static <K, V> Map<K, V> mapDifference(Map<? extends K, ? extends V> left, Map<? extends K, ? extends V> right) {
Map<K, V> difference = new HashMap<K, V>();
difference.putAll(left);
difference.putAll(right);
difference.entrySet().removeAll(right.entrySet());
return difference;
}
Is is working fine in eclipse but in jmeter it is throwing 在Eclipse中工作正常,但在jmeter中抛出
error:Method info( java.util.HashMap ) not found in class'org.apache.log.Logger' 错误:在类'org.apache.log.Logger'中找不到方法信息(java.util.HashMap)
You are trying to pass a Map to Logger while it accepts only Strings for info() , warn() , etc. methods to you will need to cast the Map to String somehow. 您正在尝试将Map传递给Logger,而Logger仅接受info() , warn()等的字符串。您将需要以某种方式将Map转换为String。
Also I don't think you have generics support in Beanshell, consider switching to JSR223 Elements and Groovy language instead. 另外,我认为您在Beanshell中没有泛型支持,请考虑改用JSR223 Elements和Groovy语言 。
try log.info(m.differenceValue(jsonElement1,jsonElement2).toString());
尝试log.info(m.differenceValue(jsonElement1,jsonElement2).toString());
according to documentation, that might work for HashMap (depending on what you have for the keys & values there) 根据文档,这可能适用于HashMap(取决于您那里的键和值)
public String toString() 公共字符串toString()
Returns a string representation of this map. 返回此映射的字符串表示形式。 The string representation consists of a list of key-value mappings in the order returned by the map's entrySet view's iterator, enclosed in braces ("{}"). 字符串表示形式由键值映射列表组成,这些键值映射由映射的entrySet视图的迭代器返回,并用大括号(“ {}”)括起来。 Adjacent mappings are separated by the characters ", " (comma and space). 相邻的映射用字符“,”(逗号和空格)分隔。 Each key-value mapping is rendered as the key followed by an equals sign ("=") followed by the associated value. 每个键值映射均表示为键,后跟等号(“ =”),后跟关联值。 Keys and values are converted to strings as by String.valueOf(Object). 键和值通过String.valueOf(Object)转换为字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.