gpt4 book ai didi

java - Spring Boot REST 资源更改未应用

转载 作者:行者123 更新时间:2023-12-01 16:22:50 26 4
gpt4 key购买 nike

我有一个非常简单的 Spring Boot 应用程序,它由 OrderJpaRepository @RepositoryRestResource 组成:

@Entity
public class Order {
@Id
@GeneratedValue
private Long recordId;

@Length(max = 64)
private String orderType;
.....
}

@RepositoryRestResource
public interface OrderRepository extends JpaRepository<Order, Long>,
QuerydslPredicateExecutor<Order> {
}

我最近将字段 orderKind 更改为 orderType。我确保数据库已更新。但是,在端点上,更改不适用。它仍然期望/返回 orderKind

我通过清理项目、删除所有生成的源并直接从命令行运行来排除任何 IDE 问题,但没有成功。

也经过验证,生成的 QOrder.java 也正确定义了 orderType

最佳答案

在写这篇文章时,发现问题很微不足道。当我重构字段名称时,我忘记更新该字段的 getter 和 setter,以便它们仍然显示:

public String getOrderKind() {
return orderType;
}

public void setOrderKind(String orderKind) {
this.orderType = orderKind;
}

作为 Spring Boot 的新手,我并没有意识到是定义 API 的方法,事后看来这似乎是显而易见的,因为这些字段是私有(private)的。

关于java - Spring Boot REST 资源更改未应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62223769/

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