我有一个 springBoot 2.1.9.RELEASE 应用程序,它使用 Spring Data for Couchbase
我有这个对象
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Hostel<T> {
@NotNull
@JsonProperty("_location")
private T location;
}
还有这个
@Document
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(of = { "id" })
@Builder
public class HTMDoc {
@Id
private String id;
@NotNull
@Field
private Hostel hostel;
}
关于服务
public HTMDoc create(@Valid HTMDoc doc) {
return repository.save(doc);
}
在测试中
service.create(new HTMDoc());
但是当我保存时,我收到了此错误,而不是旅馆字段中的验证 NotNull
org.springframework.data.mapping.MappingException: An ID property is needed, but not found/could not be generated on this entity.
慕盖茨4494581
侃侃无极
翻翻过去那场雪
ABOUTYOU
相关分类