小编aly*_*oon的帖子

Mapstruct问题:未知属性错误

我一起使用 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)

gradle annotation-processing lombok mapstruct

1
推荐指数
1
解决办法
4619
查看次数

标签 统计

annotation-processing ×1

gradle ×1

lombok ×1

mapstruct ×1