gpt4 book ai didi

java - 使用 hateoas 休息应用程序 : Multiple markers at this line

转载 作者:行者123 更新时间:2023-11-30 10:48:21 29 4
gpt4 key购买 nike

我正在尝试使用 hateoas 制作一个休息应用程序。

这是我的汇编类:

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 行(我使用 lombok)我遇到了以下错误:

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;
}

最佳答案

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

那些“多个标记”中唯一的错误是返回类型与 ResourceSupport.getId() 不兼容,其他都是警告。

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

关于java - 使用 hateoas 休息应用程序 : Multiple markers at this line,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35840098/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com