UserService.java
Java ●
01@Service02public class UserService {03 private final UserRepository repository;0405 public UserService(UserRepository repository) {06 this.repository = repository;07 }0809 public User findById(Long id) {10 return repository.findById(id)11 .orElseThrow(() -> new NotFoundException("User not found"));12 }13}