【发布时间】:2018-11-23 02:32:52
【问题描述】:
我正在使用来自 spring-boot-starter-data-rest 的 Spring Data 的 Rest 存储库,其中 Couchbase 用作下划线 DBMS。
我的对象的 Pojo 是这样设置的。
@Document
public class Item{
@Id @GeneratedValue(strategy = UNIQUE)
private String id;
@NotNull
private String name;
//other items and getters and setters here
}
并说项目的 id 为“xxx-xxx-xxx-xxx”,名称为“testItem”。
问题是,当我想访问该项目时,我需要/items/testItem 可以访问,但/items/xxx-xxx-xxx-xxx 可以访问它。
如何使用其名称而不是生成的 id 来获取数据。
【问题讨论】:
标签: spring spring-boot spring-data spring-rest