![](/img/trans.png)
[英]java.lang.IllegalStateException: Required identifier property not found
[英]java.lang.IllegalStateException: Required identifier property not found for class com.domain.Profile! - Mongo, SpringBoot
我在我的項目中使用 SpringBoot 和 Mongo。
我有一個看起來像這樣的Profile
模型。
@Data
@Document
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Profile {
private String birthDate;
private Stirng city;
private String country;
}
我可以通過郵遞員將它添加到 Mongo,但是當我嘗試通過Id
從 Mongo 中delete
它時,出現以下錯誤。
java.lang.IllegalStateException: Required identifier property not found for class com.domain.Profile!
這是 deleteById 方法。
@DeleteMapping(value = "/{profileId}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> deleteById(@PathVariable String profileId) {
if (profileRepository.existsById(profileId)) {
profileRepository.deleteById(profileId);
return new ResponseEntity<>("Profile properly deleted.",HttpStatus.OK);
} else {
return new ResponseEntity<>("Profile not found.", HttpStatus.NOT_FOUND);
}
}
我像這樣使用Postman
:
我在這里缺少什么?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.