-1
Although I know very little about Spring because I am learning, I cannot save a recovered object, the error is when I pass the object personal Pository.save(personSalva) I came to see some examples, but I found it difficult to understand due to the little knowledge I still have.
@PutMapping("/{codigo}")
public ResponseEntity<Optional<Pessoa>> atualizar(@PathVariable Long codigo, @RequestBody Pessoa pessoa) {
Optional<Pessoa> pessoaSalva = pessoaRepository.findById(codigo);
BeanUtils.copyProperties(pessoa, pessoaSalva, "codigo");
pessoaRepository.save(pessoaSalva);
return !pessoaSalva.isEmpty() ? ResponseEntity.ok(pessoaSalva) : ResponseEntity.notFound().build();
}