我是maptruct中的新手,我使用spring作为DI我跟进了关于DI容器的MapStruct文档页面4.2我尝试将我的实体映射到dto,如下所示:
@Mapper(componentModel = "spring") public interface CustomerMapper { @Mapping(source = "registered",target = "activeProfile") CustomerDto customerToCustomerDto(Customer customer); }
当我运行mvn install时出现此错误:
java:27: error: No property named "registered" exists in source parameter(s). @Mapping(source = "registered",target = "activeProfile")
我的实体使用lombok,我相信有注册的字段
请帮忙
您不必删除Lombok.你可以设置它在MapStruct之前工作,如ahus1 https://github.com/mapstruct/mapstruct/issues/510所述
org.projectlombok lombok-maven-plugin ${org.projectlombok.maven.version} generate-sources delombok src/main/java false ${project.build.directory}/delombok org.bsc.maven maven-processor-plugin 2.2.4 ${project.build.directory}/generated-sources/mapstruct org.mapstruct.ap.MappingProcessor ${project.build.directory}/delombok process generate-sources process org.apache.maven.plugins maven-compiler-plugin 3.0 lombok.launch.AnnotationProcessorHider$AnnotationProcessor