我上课
public class Monitor {
@Autowired
private QueryService;
public void perform(){
// code here
}
}
我正在使用推土机,但推土机却给了我类似的异常
org.dozer.MappingException: java.lang.NoSuchMethodException:XX.QueryService.<init>()
at org.dozer.util.MappingUtils.throwMappingException(MappingUtils.java:82) ~[dozer-core-6.0.0.jar:6.0.0]
at org.dozer.factory.ConstructionStrategies$ByConstructor.newInstance(ConstructionStrategies.java:327) ~[dozer-core-6.0.0.jar:6.0.0]
at org.dozer.factory.ConstructionStrategies$ByConstructor.create(ConstructionStrategies.java:311) ~[dozer-core-6.0.0.jar:6.0.0]
at org.dozer.factory.DestBeanCreator.applyStrategies(DestBeanCreator.java:80) ~[dozer-core-6.0.0.jar:6.0.0]
at org.dozer.factory.DestBeanCreator.create(DestBeanCreator.java:65) ~[dozer-core-6.0.0.jar:6.0.0]
at org.dozer.MappingProcessor.createByCreationDirectiveAndMap(MappingProcessor.java:220) ~[dozer-core-6.0.0.jar:6.0.0]
at org.dozer.MappingProcessor.mapCustomObject(MappingProcessor.java:548) ~[dozer-core-6.0.0.jar:6.0.0]
at org.dozer.MappingProcessor.mapOrRecurseObject(MappingProcessor.java:501) ~[dozer-core-6.0.0.jar:6.0.0]
at org.dozer.MappingProcessor.mapFromFieldMap(MappingProcessor.java:392) ~[dozer-core-6.0.0.jar:6.0.0]
at org.dozer.MappingProcessor.mapField(MappingProcessor.java:338) ~[dozer-core-6.0.0.jar:6.0.0]
at org.dozer.MappingProcessor.map(MappingProcessor.java:298) ~[dozer-core-6.0.0.jar:6.0.0]
有什么方法可以提示推土机它是Java Bean并使用现有的Bean,即按原样复制Bean而不是克隆它吗?
答案 0 :(得分:0)
推土机支持通过引用复制对象。对于此类对象不执行任何转换/变换。这种方法可以减少对象分配的数量,但是仅适用于在转换后将Java Bean丢弃(垃圾回收)的情况。如果可能,通常建议使用此方法来调整映射过程的性能。确保两个对象类型相同,否则会遇到转换问题。默认值为“ false”。
<field copy-by-reference="true">
<a>copyByReference</a>
<b>copyByReferencePrime</b>
</field>