我正在尝试使用 mapstruct 将本地 pojo 映射到自动生成的域对象。期望一个特定的复杂结构,其他一切似乎都映射,并且映射器实现类得到生成。以下是我得到的错误。
我的映射器类是:
@Mappings({
@Mapping(source = "sourcefile", target = "sourceFILE"),
@Mapping(source = "id", target = "ID"),
@Mapping(source = "reg", target = "regID"),
@Mapping(source = "itemDetailsType", target = "ItemDetailsType") //This is the structure that does not map
})
AutoGenDomainType map(LocalPojo localPojo);
@Mappings({
@Mapping(source = "line", target = "LINE"),
@Mapping(source = type", target = "TYPE")
})
ItemDetailsType map(ItemDetailsTypes itemDetailsType);
错误:
Internal error in the mapping processor: java.lang.NullPointerException at org.mapstruct.ap.internal.processor.creation.MappingResolverImpl$ResolvingAttempt.hasCompatibleCopyConstructor(MappingResolverImpl.java:547) at org.mapstruct.ap.internal.processor.creation.MappingResolverImpl$ResolvingAttempt.isPropertyMappable(MappingResolverImpl.java:522) at org.mapstruct.ap.internal.processor.creation.MappingResolverImpl$ResolvingAttempt.getTargetAssignment(MappingResolverImpl.java:202) at org.mapstruct.ap.internal.processor.creation.MappingResolverImpl$ResolvingAttempt.access$100(MappingResolverImpl.java:153) at org.mapstruct.ap.internal.processor.creation.MappingResolverImpl.getTargetAssignment(MappingResolverImpl.java:121) at
.....
.....
[ERROR]
[ERROR] Found 1 error and 16 warnings.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project uwo-services: Compilation failure
目标对象ItemDetailsType
确实具有不需要映射的其他属性。该错误表示编译问题,但我没有找到任何问题。此外,我尝试添加unmappedTargetPolicy = ReportingPolicy.IGNORE
在我的映射器类级别尝试过,只是为了避免这是由未映射的属性引起的,但仍然没有解决方案。