Skip to content

Mapping annotation field name is different from entity field name #122

@CurryPotato

Description

@CurryPotato

mapstruct version: 1.4.1.Final
jdk version: 8

public class Driver {
    private String sourceName;
    private String pathName;
}

public class DriverDTO {
    private String szName;
    private String pName;
}

@Mapper
public interface DriverMapper {
    @Mapping(source = "sourceName", target = "szName")
    @Mapping(source = "parentName", target = "pName")
    DriverDTO driverToDriverDTO(Driver driver);
}

when I compile these class, I get a compile error.

Error:(26, 12) java: Unknown property "pName" in result type DriverDTO. Did you mean "PName"?

but I make target = "pName" -> target = "PName" , I get a correct result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions