我正在尝试使用下面的代码来比较两个对象值并打印mismtach:
BeanMap map = new BeanMap(ep);
PropertyUtilsBean propUtils = new PropertyUtilsBean();
for (Object propNameObject : map.keySet()) {
String propertyName = (String) propNameObject;
Object expectedValue = propUtils.getProperty(ep, propertyName);
Object actualValue = propUtils.getProperty(ap, propertyName);
if (!expectedValue.equals(actualValue)) {
WorkloadGeneratorLogger.log("> " + propertyName
+ " is different (oldValue=\"" + expectedValue
+ "\", newValue=\"" + actualValue + "\")");
}
}
使用beanMap时出现以下错误:
线程“main”中的异常java.lang.NoClassDefFoundError:org / apache / commons / beanutils / BeanMap
.....................
由java.lang.ClassNotFoundException引起:org.apache.commons.beanutils.BeanMap
以下是我的pom.xml条目:
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.3</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
不确定这里错过了什么,我尝试了以下链接建议的相同组合罐:
java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer
http://commons.apache.org/proper/commons-beanutils/dependencies.html
仍然无法解决这个问题。