Java 映射未应用于子类

Java 映射未应用于子类,java,mapstruct,Java,Mapstruct,我有以下映射: @Mapper public interface ParticulierMapper { ParticulierMapper INSTANCE = Mappers.getMapper( ParticulierMapper.class ); TParticulier toDTO(Particulier particulier); Particulier toEntity(TParticulier particulier); TParticulierAttributMeta toD

我有以下映射:

@Mapper
public interface ParticulierMapper {

ParticulierMapper INSTANCE = Mappers.getMapper( ParticulierMapper.class );
TParticulier toDTO(Particulier particulier);
Particulier toEntity(TParticulier particulier);
TParticulierAttributMeta toDTO(ParticulierAttributMeta particulierAttributMeta);
ParticulierAttributMeta toEntity(TParticulierAttributMeta particulierAttributMeta);
TAdresse toDTO(Adresse adresse);
Adresse toEntity(TAdresse adresse);

default String toEntity(TGufidValue value){
    return value.getGufid();
}
default TGufidValue toDTO(String value){
    TGufidValue tGufidValue=new TGufidValue();
    tGufidValue.setGufid(value);
    return tGufidValue;
}
default LocalDateTime map(XMLGregorianCalendar value){
    return value.toGregorianCalendar().toZonedDateTime().toLocalDateTime();
}
}`
TGufidValue已正确转换为TParticulier/Particulier,但已跳过Adresse/TADRESS转换,如图所示:

public Adresse toEntity(TAdresse adresse) {

    if ( adresse == null ) {

        return null;
    }

    Adresse adresse1 = new Adresse();

    adresse1.setLibelleAdresse( adresse.getLibelleAdresse() );

    adresse1.setParticulierAttributMetas( tParticulierAttributMetaListToParticulierAttributMetaList( adresse.getParticulierAttributMetas() ) );

    adresse1.setBoite( adresse.getBoite() );

    adresse1.setComplement( adresse.getComplement() );

    adresse1.setLocalisationSpatiale( adresse.getLocalisationSpatiale() );

    adresse1.setLocalite( adresse.getLocalite() );

    adresse1.setNumero( adresse.getNumero() );

    adresse1.setRegion( adresse.getRegion() );

    adresse1.setVille( adresse.getVille() );

    adresse1.setVoie( adresse.getVoie() );

    return adresse1;
}
所有属于TGufidValue对象的TadAddress字段都将被跳过,因此不会出现在Tadress转换中。
是否有什么特别的事情可以让这种转换在Tpaticulier/Particulier以外的其他类上全局可用?

尽管我发现了我的问题。只是在使用TGufidValue时,dto和entity字段没有相同的名称。编译时可能会出现一个警告,指出存在一些不匹配的字段。

如果目标bean中的属性(在您的例子中为
adrese
未映射),则应该会收到一个警告。您甚至可以使构建失败,即报告错误。看一看这张照片。如果真的没有警告,请打开一个问题