【问题标题】:Rest application using hateoas: Multiple markers at this line使用 hatoas 的休息应用程序:此行有多个标记
【发布时间】:2016-06-20 18:55:08
【问题描述】:

我正在尝试使用 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;
}

【问题讨论】:

    标签: java rest spring-mvc lombok


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-11
      • 1970-01-01
      • 2015-04-23
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多