我一起使用 mapstruct 和 lombok 并遇到了一些问题:
EntityMapper.java:10: error: Unknown property "id" in result type Entity. Did you mean "null"?
@Mapping(target = "id", ignore = true)
^
Run Code Online (Sandbox Code Playgroud)
我的 Entity 和 EntityDto 类:
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Entity {
private int id;
private String property;
}
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
public class EntityDto {
private String property;
}
Run Code Online (Sandbox Code Playgroud)
实体映射器:
@Mapper(implementationName = "MapStruct<CLASS_NAME>")
public interface EntityMapper {
// neither of them work
@Mapping(target = "id", ignore = true)
//@Mapping(target = "id", defaultValue …Run Code Online (Sandbox Code Playgroud)