I am using SpringBoot with Mongo in my project.
I have a Profile
model that looks like this.
@Data
@Document
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Profile {
private String birthDate;
private Stirng city;
private String country;
}
I can add it to Mongo via postman but when I try to delete
it from Mongo by Id
I am getting following error.
java.lang.IllegalStateException: Required identifier property not found for class com.domain.Profile!
This is deleteById method.
@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);
}
}
I use Postman
like this:
What am I missing here?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.