如何提示推土机复制自动装配的 bean 而不是克隆?
How to hint dozer to copy autowired beans instead of cloning?
我有class
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]
有什么方法可以提示 dozer 这是 java bean 并使用现有的 bean,即按原样复制 bean 而不是克隆它?
Dozer supports copying an object by reference. No conversion/transformation is done for such objects. This approach allows to decrease a number of object allocations, but is applicable only when Java Beans are to be thrown away (Garbage Collected) after transformation. This approach is generally recommended for performance tuning of the mapping process when possible. Make sure that both object types are the same or you will run into casting problems. The default value is 'false'.
<field copy-by-reference="true">
<a>copyByReference</a>
<b>copyByReferencePrime</b>
</field>
我有class
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]
有什么方法可以提示 dozer 这是 java bean 并使用现有的 bean,即按原样复制 bean 而不是克隆它?
Dozer supports copying an object by reference. No conversion/transformation is done for such objects. This approach allows to decrease a number of object allocations, but is applicable only when Java Beans are to be thrown away (Garbage Collected) after transformation. This approach is generally recommended for performance tuning of the mapping process when possible. Make sure that both object types are the same or you will run into casting problems. The default value is 'false'.
<field copy-by-reference="true">
<a>copyByReference</a>
<b>copyByReferencePrime</b>
</field>