简体   繁体   English

在类'org.apache.log.Logger'中找不到方法info(java.util.HashMap)

[英]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.

相关问题 未找到有关类的消息正文编写器:类java.util.HashMap - No message body writer found for class : class java.util.HashMap 未找到类型为java.util.HashMap的返回值的转换器 - No converter found for return value of type: class java.util.HashMap java.util.HashMap 类的 keySet() 方法的时间复杂度是多少? - What is the time complexity of java.util.HashMap class' keySet() method? java.util.hashMap中的init方法 - init method in java.util.hashMap java.lang.IllegalArgumentException:未找到类型为java.util.HashMap的返回值的转换器 - java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.HashMap 找不到媒体类型 = 应用程序/xml,类型 = 类 java.util.HashMap$Values 的 MessageBodyWriter - MessageBodyWriter not found for media type=application/xml, type=class java.util.HashMap$Values HttpMessageNotWritableException:未找到类型的返回值的转换器:class java.util.HashMap 在 Z381008EDD81C2 中 - HttpMessageNotWritableException: No converter found for return value of type: class java.util.HashMap in Spring MVC 缺少java.util.HashMap - Missing java.util.HashMap 创建一个作为java.util.HashMap类扩展的类 - Creating a class that is an extension of the java.util.HashMap class FlexJson 错误:ClassCastException:java.util.HashMap 无法转换为类 - FlexJson Error : ClassCastException: java.util.HashMap cannot be cast to class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM