-3
I’m making an Api where I need to get a user’s information through findById, but the STATUS in Postman is like 200 and did not display anything. Code below.
controller
@RestController
@RequestMapping("/bank")
public class ClienteController {
@Autowired
ClienteService clienteService;
//Listar todos os cliente
@GetMapping("/cliente")
public List<Cliente> findAll() {
return clienteService.findAll();
}
//Procurar por apenas 1 cliente
// não esta funcionando. http 200 mas não aparece informação.
@GetMapping("/cliente/{id}")
public void clienteFindById(@PathVariable("id")Long id, @RequestBody Cliente clientes ){
clienteService.clienteFindById(clientes, id);
}
}
Service
@Service
public class ClienteService {
@Autowired
ClienteRepository clienteRepository;
public List<Cliente> findAll(){
return clienteRepository.findAll() ;
}
public Optional<Cliente> clienteFindById(Cliente clientes, Long id) {
return clienteRepository.findById(id);
}
}
Add the source code as text to the question. Learn more Welcome to [en.so]! You have placed a code image and/or error message. Although it sounds like a good idea, it’s not! One of the reasons is that if someone wants to answer the question, they can’t copy the code and change something inside. Click on the [Edit] link and put the code/error as text. See more about this in these links - Manual on how NOT to ask questions, Post Error Message as Picture.
– Danizavtz