我有2个具有相同“链接”属性的对象,当使用Orika从A
-> B
进行映射时,我得到
ma.glasnost.orika.MappingException:ma.glasnost.orika.MappingException:
While attempting the following mapping:
sourceType = A
sourceProperty = links(Links)
destinationType = B
destinationProperty = links(Links)
Error occurred: java.lang.NullPointerException
Caused by: ma.glasnost.orika.MappingException: java.lang.NullPointerException
at ma.glasnost.orika.impl.generator.MapperGenerator.addMapMethod(MapperGenerator.java:170)
at ma.glasnost.orika.impl.generator.MapperGenerator.build(MapperGenerator.java:70)
... 49 common frames omitted
Caused by: java.lang.NullPointerException: null
at ma.glasnost.orika.impl.generator.VariableRef.isPrimitive(VariableRef.java:167)
at ma.glasnost.orika.impl.generator.VariableRef.<init>(VariableRef.java:95)
at ma.glasnost.orika.impl.generator.specification.MapToMap.generateMappingCode(MapToMap.java:71)
at ma.glasnost.orika.impl.generator.SourceCodeContext.mapFields(SourceCodeContext.java:778)
at ma.glasnost.orika.impl.generator.MapperGenerator.generateFieldMapCode(MapperGenerator.java:247)
at ma.glasnost.orika.impl.generator.MapperGenerator.addMapMethod(MapperGenerator.java:167)
... 50 common frames omitted
对象的定义如下:
class A {
private Links links
// getter/setter + other fields
}
class B {
private Links links
// getter/setter + other fields
}
class Links extends HashMap<String, List<Link>> {
}
class Link {
private String text;
}
我正在使用默认的映射器,如下所示:
mapper.classMap(A.class, B.class)
.byDefault()
.register();
有什么建议吗?
最佳答案
您正在看到以下内容:
https://code.google.com/archive/p/orika/issues/170
它说问题已在此处解决,但在我看来却不一样:https://github.com/orika-mapper/orika/issues/67
也许这就是您所看到的:
https://github.com/orika-mapper/orika/issues/232
您的问题看起来与在code.google.com上发布的问题相同