PlantInventoryEntryDTO

PlantInventoryEntryDTO

我正在尝试使用hateoas创建一个rest应用程序。

这是我的assembelr课程:

public class PlantInventoryEntryAssembler extends ResourceAssemblerSupport<PlantInventoryEntry, PlantInventoryEntryDTO>
{
}


PlantInventoryEntryDTO类是:

@Data
public class PlantInventoryEntryDTO  extends ResourceSupport{

    Long id;
    String name;
    String description;
    @Column(precision = 8, scale = 2)
    BigDecimal price;

    public Long idGetter (){

        return  id;
    }
}


问题是,在@Data行中(我使用龙目岛),我遇到了以下错误:

Multiple markers at this line
    - overrides org.springframework.hateoas.ResourceSupport.equals
    - The return type is incompatible with ResourceSupport.getId()
    - Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If
     this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type.
    - overrides org.springframework.hateoas.ResourceSupport.toString
    - overrides org.springframework.hateoas.ResourceSupport.hashCode
    - overrides org.springframework.hateoas.ResourceSupport.getId


我该如何处理?

更新:

PlantInventoryEntry类

@Entity
@Data
public class PlantInventoryEntry {

    @EmbeddedId
    PlantInventoryEntryID id;

    String name;
    String description;

    @Column(precision = 8, scale = 2)
    BigDecimal price;
}

最佳答案

重命名id中的字段PlantInventoryEntryDTO(例如,entryId)。

这些“多个标记”中的唯一错误是The return type is incompatible with ResourceSupport.getId(),其他错误是警告。

ResourceSupport定义返回类型为LinkgetId() method。 Lombok尝试为long中的id字段添加另一个返回类型为PlantInventoryEntryDTO的getId()方法。由于它们的返回类型不兼容,因此编译器不会覆盖原始方法。

07-25 23:53