Spring/튜토리얼

Spring Boot 시작 시 도움되는 라이브러리 모음

Hamp 2025. 10. 25. 22:33
반응형

👋 들어가기 전

 

오늘은 스프링 부트 초반에 시작할 때, 도움을 줄 수 있는 추천 라이브러리 몇가지를

학습해보려고한다.

 

학습하면서 계속 추가될 예정, 물론 기초로 사용할 수 있는 난이도를 가진 라이브러리 위주로

 

학습이 크게 필요하면 별도로 포스팅함


🏁 학습할 내용

  • Spring Boot Devltools

🔬Spring Boot Devtool

 

🤔없으면 어떤 불편한 점이 있을까?

 

우리는 코드테스트를 위해, 여러번 실행하고 멈추고 반복을 하는 과정을 거친다.

 

코드가 많이 없고, 가벼울 때는 시간도 많이 안걸려서 크게 상관없지만,

프로젝트가 무거워질수록, 재시작인 생각보다 부담되는 작업이다

 

Boot Devtool은 바로 이점을 해결해준다.

 

🧩 역할

 

공식문서를 살펴보자.

Automatic Restart

Applications that use spring-boot-devtools 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 that points to a directory is monitored for changes. Note that certain resources, such as static assets and view templates, do not need to restart the application.

 

코드 변경을 감지하여, 애플리케이션을 다시 시작 시켜준다.

이때, 프로젝트 코드를 포함하는 클래스 로더만 다시 로드하고, 스플링 애플리케이션 컨텍스트를 다시 시작한다.

 

여기서 재시작에 제외되는 파일은, 정적 리소스, 템플릿, 테스트 코드등 애플리케이션 동작에 없는 파일들이다.

 

 

🎲 설치

 

이 때, 주의할 점은 이 동작은 애플리케이션 배포에는 영향이 없어야하므로, 개발 단계에서만

동작하도록 해야하므로, developmentOnly로 설치한다.

 

// build.gradle.kts

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

 

⚙️ 설정

 

1️⃣컴파일러 설정

 

File > Settings 또는 Ctrl + , 를 눌러 세팅으로 이동

Build, Execution, Deployment > Compiler > Build project automatically 체크 ✅ 

 

2️⃣고급 설정

 

Advanced Settings > Allow auto-make to start even if developed application is currently runnig

 

🤖사용

package com.example.demo
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.ResponseBody


@Controller
class HelloController {

    @GetMapping("/hello")
    @ResponseBody
    public fun hello(): String {
        return  "Hello World" // 여기를 Hello Spring Boot으로 바꿀 예정
    }
}

 


출처

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

 

Developer Tools :: Spring Boot

Applications that use spring-boot-devtools 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 tha

docs.spring.io

 

반응형