spring.jpa.open-in-view is enabled by default.

By | 2026년 2월 13일
Table of Contents

spring.jpa.open-in-view is enabled by default.

Spring Boot의 기본 설정은 spring.jpa.open-in-view=true입니다. 이 설정 덕분에 개발자는 지연 로딩(Lazy Loading)을 아주 편하게 사용할 수 있습니다. 트랜잭션이 끝난 후 컨트롤러나 HTML 템플릿(Thymeleaf 등)에서도 연관된 데이터를 자유롭게 조회할 수 있기 때문이죠.

spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning

해결책

아래 설정으로 위 경고를 제거할 수 있습니다.
다만, 데이터베이스 커넥션은 Service 계층의 트랜잭션(@Transactional)이 끝나는 순간 반납됩니다.

# application.yml
spring:
  jpa:
    open-in-view: false

답글 남기기