I am working on a Spring Boot project. I just have annotation configuration. I want to include dozer to transform Entities to DTO and DTO to Entities. I see in the dozer web
Just in case someone wants to avoid xml dozer file. You can use a builder directly in java. For me it's the way to go in a annotation Spring context.
See more information at mapping api dozer
@Bean
public DozerBeanMapper mapper() throws Exception {
DozerBeanMapper mapper = new DozerBeanMapper();
mapper.addMapping(objectMappingBuilder);
return mapper;
}
BeanMappingBuilder objectMappingBuilder = new BeanMappingBuilder() {
@Override
protected void configure() {
mapping(Bean1.class, Bean2.class)
.fields("id", "id").fields("name", "name");
}
};
In my case it was more efficient (At least the first time). Didn't do any benchmark or anything.