JPA를 이용해 새 게시물을 추가하기 위해 JpaRepository를 상속받는 PostRepository를 생성합니다. @Repository public interface PostRepository extends JpaRepository
@PostMapping("/users/{id}/posts") public ResponseEntity createPost(@PathVariable int id, @RequestBody Post post){ Optional user = userRepository.findById(id); if(user.isEmpty()) throw new UserNotFoundException(String.format("ID[%s] not found", id)); post.setUser(user.get()); Post save...