spring-boot-devtools

2024. 8. 3. 06:10SPRING

https://docs.spring.io/spring-boot/docs/1.5.16.RELEASE/reference/html/using-boot-devtools.html

 

20. Developer tools

Applications that use spring-boot-devtools will automatically restart whenever files on the classpath change. This can be a useful feature when working in an IDE as it gives a very fast feedback loop for code changes. By default, any entry on the classpath

docs.spring.io

 

ClassPath에 있는 파일이 수정 됐을 때, 어플리케이션 재실행 없이도, 수정사항을 반영해줌.

html, css, javascript 등 비지니스 로직과 연관 없는 애들 수정했을 때, 즉각 반영 해주니 개발할 때 유용한 기능임.

 

Property defaults

각종 라이브러리, 템플릿 엔진 사용 시 반복되는 작업, 반복 사용되는 자원을 절약하기 위해 Cache 기술이 사용됨.

수정이 잦은 작업 특성상, 캐싱과 캐시는 오히려 독이 됨.

spring dev tools 는 caching 을 막고, 자원 업데이트를 즉각적으로 반영. 리스폰스 함으로써 개발 생산성에 기여함.

 

 

환경

- IDE : 인텔리 제이

- JAVA : JDK_22

- Spring Framework : 3.3.2

 

적용 방법

1. 복사 그리고 붙여넣기

 

1. 공홈에 있는 코드 복붙
*맨 아래 추가 내용 있음. **compileOnly() 

dependencies {
    compileOnly("org.springframework.boot:spring-boot-devtools")
}

2. mvnRepository 에서 검색한 코드 복붙

// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-devtools
implementation group: 'org.springframework.boot', name: 'spring-boot-devtools', version: '3.3.2'

 

1, 2 의 공통점

build.gradle 파일의 dependencies { 내용 } 에 넣어줘야 함.

1, 2 의 차이점

1. compileOnly() : 컴파일 시에만 주입되는 DI. 버전 입력 불필요함.

2. implementation : 런타임 시에도 주입되는 DI. 버전 입력 필요. 입력 버전에 따라 오류 발생할 수 있음.

 

spring boot devtools 는 개발 시에만 쓰고 런타임에는 쓸 일이 없어보이므로, 1번이 옳다고 판단됨.

 


2. IDE(본인의 경우 인텔리제이) 설정 수정

Build, Execution, Deployment - Compiler - Build project automatically 체크

Advanced Setting - Compiler - Allow auto0make to start even if de -- 체

 

Run/Debug Configurations - Build And Run - Modify Options - 업데이트 시 -  update resources

(클래스들도 하고 싶으면 밑에걸루)

 

 

**compileOnly()

developmentOnly() 등도 있는 모양인데, 스프링에서는 compileOnly 가 베스트 프랙티스라 함.

 

 

-----

누군가 이걸 보고 부족하거나 잘못됐다고 생각한다면 피드백 부탁드립니다.

'SPRING' 카테고리의 다른 글

데이터 전달 방식 - API  (0) 2024.08.04
build 해보기  (0) 2024.08.03
테스트_@Transactional  (0) 2024.02.27
스프링 빈 등록 방법  (0) 2024.02.25
의존 주입  (0) 2024.02.25