[Spring Boot] JPA 즉시 로딩과 지연 로딩(FetchType.EAGER or LAZY)

[Spring Boot] JPA 즉시 로딩과 지연 로딩(FetchType.EAGER or LAZY)

블로그 프로젝트 진행 중 FetchType.LAZY와 EAGER이란 것이 나왔다.

하나의 게시물을 눌렀을 때, 화면에 필수적으로 나타나야 하는 것은

  • 작성자
  • 제목
  • 내용

위 3가지가 있었고 있었고, 댓글은 바로 보여지는 경우와 접혀있다가 눌렀을 때 보이는 경우로 나눌 수 있었다.


JPA의 기본 패치 전략

- @ManyToOne, @OneToOne: 즉시로딩(FetchType.EAGER)

자세히 보기
[Spring Boot] IntelliJ에서 Live Reload 설정하기

[Spring Boot] IntelliJ에서 Live Reload 설정하기

Live Reload

  • Live Reload라는 기능은 Spring Boot로 개발하면서 자바 소스를 수정하고 저장하면 자동으로 재시작을 해주는 기능이다.

1. spring-boot-devtools 의존성 추가하기

1
developmentOnly 'org.springframework.boot:spring-boot-devtools'

2. application.yml에 추가하기

1
2
3
4
5
6
7
8
9
spring:
devtools:
livereload: # view단이 바뀌었을 때 자동으로 리로드 설정
enabled: true
restart: # 컨트롤러,모델단(classpath에 있는 파일)이 바뀌었을 때 프로젝트 재시작 설정
enabled: false

freemarker:
cache: false

3. Intelli J 설정 수정하기

자세히 보기
[Spring Boot] 블로그 프로젝트 기본 세팅하기

[Spring Boot] 블로그 프로젝트 기본 세팅하기

기본 셋팅

프로그램

Windows 10
-----------------
IntelliJ : 코드작성

Docker - MySQL

MySQL Workbench

Postman

의존성 추가

springboot devtools

lombok

spring data JPA

mysql driver

spring security

spring web

​ OAuth2 client는 직접구현해보기

1
2
3
4
5
6
7
8
9
10
11
12
13
14
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'mysql:mysql-connector-java'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'

/** 추가 라이브러리 **/
implementation "org.springframework.security:spring-security-taglibs" // 시큐리티 태그 라이브러리
implementation "org.apache.tomcat.embed:tomcat-embed-jasper" // JSP 템플릿 엔진
implementation 'javax.servlet:jstl' // JSTL
자세히 보기
[Spring Boot] IntelliJ 학생인증, Ultimate 무료설치하기
[Spring Boot] IntelliJ로 Spring Boot 시작하기