推土机问题:没有为类中的字段(状态)找到读取或写入方法

时间:2016-05-18 09:30:39

标签: java mapping dozer

这是我在dozermap.xml文件中的映射:

org.dozer.MappingException: No read or write method found for field (status) in class (class com.models.TestModel)
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.determinePropertyType(GetterSetterPropertyDescriptor.java:319)
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.getPropertyType(GetterSetterPropertyDescriptor.java:76)
at org.dozer.fieldmap.FieldMap.getDestFieldType(FieldMap.java:117)
at org.dozer.util.MappingUtils.applyGlobalCopyByReference(MappingUtils.java:212)
at org.dozer.loader.MappingsParser.processMappings(MappingsParser.java:168)
at org.dozer.loader.CustomMappingsLoader.load(CustomMappingsLoader.java:49)
at org.dozer.DozerBeanMapper.loadCustomMappings(DozerBeanMapper.java:213)
at org.dozer.DozerBeanMapper.initMappings(DozerBeanMapper.java:315)
at org.dozer.DozerBeanMapper.getMappingProcessor(DozerBeanMapper.java:192)
at org.dozer.DozerBeanMapper.map(DozerBeanMapper.java:120)
at com.helpers.GeneralHelper.mapDomainModelToKey(GeneralHelper.java:226)
at com.helpers.GeneralHelper.updateKeys(GeneralHelper.java:130)
at com.helpers.GeneralHelperTest.addKeys(GeneralHelperTest.java:295)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)

映射工作正常,只有在我尝试运行junit测试时才会发生此错误。

堆栈跟踪:

//Create NSSet from Array

NSSet* oldset = [NSSet setWithArray:oldArray];
NSSet* newset = [NSSet setWithArray:newArray];

// retrieve the Name of the objects in newset
NSSet* newset_names = [newset valueForKey:@"Name"]; 
// only keep the objects of oldset whose 'Name' are not in newset_names
NSSet* oldset_minus_newset = [oldset filteredSetUsingPredicate:
    [NSPredicate predicateWithFormat:@"NOT Name IN %@",newset_names]];

//And Same can be used for find newset not have name in oldset 

// retrieve the Name of the objects in oldset
NSSet* oldset_names = [oldset valueForKey:@"Name"]; 
// only keep the objects of newset whose 'Name' are not in oldset_names
NSSet* new_minus_oldset = [newset filteredSetUsingPredicate:
    [NSPredicate predicateWithFormat:@"NOT Name IN %@",oldset_names]];

//Now convert back to Array from sets
NSArray *new_minus_oldArray = [new_minus_oldset allObjects];
NSSet* oldset_minus_newArray = [oldset_minus_newset allObjects];

1 个答案:

答案 0 :(得分:0)

从日志消息中,您似乎没有com.models.TestModel类的映射。您可以在测试资源中添加相关映射,也可以在测试类安装程序中执行此操作。推土机docs有一些例子。