문제 요약
/todos API 호출 시 jakarta.servlet.ServletException 발생
문제 상세


에러 로그 원문
jakarta.servlet.ServletException: Request processing failed: org.springframework.orm.jpa.JpaSystemException: could not execute statement [Connection is read-only. Queries leading to data modification are not allowed] [insert into todos (contents,created_at,modified_at,title,user_id,weather) values (?,?,?,?,?,?)]
문제 원인 추정
Connection is read-only 라는 점에서 saveTodo가 읽기 전용 메서드로 선언되어 있을 것이고, 그 결과 업데이트 쿼리가 날아갈 수 없었다.
문제 원인 확인
모든 메서드에 readOnly = true가 적용되어 있었다.

해결 방법 요약
readOnly = true 옵션 삭제
해결 방법 상세

결과
정상 실행 확인

인사이트
클래스명에 @Transactional을 붙여서 모든 메서드에 일괄적으로 적용할 수 있다
'Projects > [Spring] Code Refactoring Project' 카테고리의 다른 글
| [Spring Plus] AOP의 동작 흐름 제어하기 (0) | 2026.02.28 |
|---|---|
| [Spring Plus] 컨트롤러 테스트 성공시키기 (0) | 2026.02.28 |
| [Spring Plus] JPQL로 쿼리 옵션 추가하기 (0) | 2026.02.27 |
| [Spring Plus] JWT 인증 필드 추가 (0) | 2026.02.27 |
| 일정 관리 프로젝트 개발일지(2025.12~2026.1) (0) | 2026.01.02 |