The method getId() is undefined for the type

我正在学习Spring boot,遇到了一个问题。我创建了一个Expense类,如下所示:

    @AllArgsConstructor
@NoArgsConstructor
@Entity
@Data
@Table(name="expense")
public class Expense {
    @Id
    private Long id;

    private Instant expensedate;

    private String description;

    private String location;

    @ManyToOne
    private Category category;

    @JsonIgnore
    @ManyToOne
    private User user;
}

现在我正试图创建一个 "控制 "来 "添加/删除 "支出对象。以下是创建Expense对象的方法:

@PostMapping("/expenses")
ResponseEntity<Expense> createExpense(@Valid @RequestBody Expense expense) throws URISyntaxException{
    Expense result = expenseRepository.save(expense);
    return ResponseEntity.created(new URI("/api/expense" + result.getId())).body(result);
}

但在这个方法中,我得到了以下错误:

The method getId() is undefined for the type Expanse

你是否在你的IDE中安装了lombok插件?

https://projectlombok.org/download