I want customer details by using emailId otherwise I want email not found ,but I'm getting dependency error. Anyone help to sort out of this issue.
Controller
1. @GetMapping("/get/{email}")
public Customer getCustomerByEmail(@PathVariable String email) {
return customerService.findByEmail(email);
}
}
CustomerServiceImp
2. @Override
public Customer findByEmail(String email) {
Optional<Customer> customer = customerRepository.findByEmail(email);
if (customer.isPresent()) {
return customer.get();
}else{
throw new RuntimeException("Customer is not Found"+email);
}
}
Repo
3. @Repository
public interface CustomerRepository extends JpaRepository<Customer, Integer> {
Optional<Customer> findByEmail(String email);
CustomerService
Customer findByEmail(String email);