问题
I don't understand why, but whenever I do put operation in postman this method always creates new vehicle This is code for put mapping
@PutMapping("/{id}")
public Vehicle updateVehicle(@PathVariable long id, @RequestBody Vehicle vehicle){
vehicle.setVehicleId(id);
return vehicleRepository.saveAndFlush(vehicle);
}
This is code for post mapping
@PostMapping("")
public Vehicle newVehicle(@RequestBody Vehicle vehicle){
return vehicleRepository.saveAndFlush(vehicle);
}
来源:https://stackoverflow.com/questions/61920671/put-makes-post-instead-of-updating-value-in-spring-boot