java - 在类“org.apache.log.Logger”中找不到方法信息(java.util.HashMap)

标签 java apache jmeter beanshell

 log.info(m.differenceValue(jsonElement1,jsonElement2)); 

从 beanshell 调用函数。代码在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;
}

在 Eclipse 中工作正常,但在 jmeter 中它抛出

error:Method info( java.util.HashMap ) not found in class'org.apache.log.Logger'

最佳答案

尝试log.info(m.differenceValue(jsonElement1,jsonElement2).toString());

根据文档,这可能适用于 HashMap(取决于您那里的键和值)

public String 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 ("{}"). 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).

关于java - 在类“org.apache.log.Logger”中找不到方法信息(java.util.HashMap),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43390754/

相关文章:

windows - Apache 端口问题

json - JMeter 可以将 JSON 路径断言插件与数组匹配吗?

apache - 当 SSL 证书为非 www 时,在 https www 上将 www 重写为非 www 失败

java - 插件 org.apache.maven.plugins :maven-install-plugin:2. 4 或其依赖项之一无法解析

java - Java 中的随机数生成器

java - 当页面大小小于记录大小时,带有分页的 native 查询会引发内部服务器错误

css - 与 CSS/JS/图像相关的 Wordpress 站点的多个子响应导致 Jmeter 中的响应时间延迟

java - 使用 Jmeter 对消费者和生产者进行测试

java - 设置 Cassandra Liquibase

java - 如何对包含字符串数组的数组列表进行排序?