application-${Active profiles}.properties Run -> Edit Configurations -> Active profiles setting
application.properties
server.port=8182
server.shutdown=graceful
spring.application.name=spring-playground
# docker mysql
spring.jpa.hibernate.ddl-auto=validate
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=override
spring.datasource.username=override
spring.datasource.password=overrideapplication-local.properties
spring.datasource.url=jdbc:mysql://localhost:3306/spring_playground
spring.datasource.username=playground
spring.datasource.password=playground./gradlew clean build ${options}- -Dorg.gradle.java.home=${java_home}: 특정 JDK 버전으로 빌드
- -Dspring.profiles.active=${profile}: 특정 프로파일로 빌드
# foreground
java -jar playground.jar --spring.profiles.active=${profile} --jasypt.encryptor.password=${password}
# background
nohup java -jar playground.jar --spring.profiles.active=${profile} --jasypt.encryptor.password=${password} > /dev/null 2>&1 &application.properties에 Actuator 설정 추가:
# Actuator 기본 경로 설정
management.endpoints.web.base-path=/actuator
management.endpoint.health.show-details=when-authorized
# 노출할 엔드포인트 설정
management.endpoints.web.exposure.include=health,info,metrics,env,beans
# 또는 모든 엔드포인트 노출 (운영 환경에서는 권장하지 않음)
# management.endpoints.web.exposure.include=*
# Health 체크 상세 정보 표시
management.endpoint.health.show-components=alwayscurl http://localhost:9000/actuator/health# 애플리케이션 정보
curl http://localhost:9000/actuator/info# 모든 메트릭 조회
curl http://localhost:9000/actuator/metrics
# 특정 메트릭 조회 (예: jvm.memory.used)
curl http://localhost:9000/actuator/metrics/jvm.memory.used# 환경 변수 및 설정 정보
curl http://localhost:9000/actuator/env# Spring Bean 목록
curl http://localhost:9000/actuator/beans# 모든 엔드포인트 목록 조회
curl http://localhost:9000/actuator참고: /actuator/health 엔드포인트는 Spring Boot의 기본 동작으로 Spring Security가 활성화되어 있어도 별도 설정 없이 접근 가능합니다.
다른 Actuator 엔드포인트들(info, metrics, env, beans 등)에 접근하려면 Spring Security 설정이 필요합니다.
현재 프로젝트에서는 SecurityConfig의 publicEndPoints()에 /actuator/** 경로가 추가되어 모든 Actuator 엔드포인트에 접근 가능합니다:
private RequestMatcher publicEndPoints() {
return new OrRequestMatcher(
new AntPathRequestMatcher("/api/**"),
/* websocket */
new AntPathRequestMatcher("/ws/chat"),
/* actuator */
new AntPathRequestMatcher("/actuator/**")
);
}운영 환경에서는 보안을 위해 health만 public으로 두고 나머지 엔드포인트는 인증을 추가하는 것을 권장합니다:
// 예시: health는 기본적으로 public이므로 별도 설정 불필요
// 나머지 엔드포인트만 필요시 추가
private RequestMatcher publicEndPoints() {
return new OrRequestMatcher(
new AntPathRequestMatcher("/api/**"),
new AntPathRequestMatcher("/ws/chat")
// /actuator/health는 자동으로 허용됨
);
}- 헬스 체크: Kubernetes, Docker 등의 오케스트레이션 도구에서 애플리케이션 상태 확인
- 모니터링: 메트릭 수집 및 모니터링 시스템 연동 (Prometheus, Grafana 등)
- 디버깅: 환경 변수, Bean 정보 등 런타임 정보 확인