application.yml 키워드들Spring Boot는 application.yml 또는 application.properties에서 미리 정해진 키워드(속성)들을 제공합니다.
이 속성들은 Spring이 자동으로 인식하여 특정 기능을 활성화하거나 설정을 조정하는 역할을 합니다.
다음은 자주 사용하는 Spring Boot의 공식적인 설정 키워드들입니다.
spring:
application:
name: MyApp # 애플리케이션 이름 설정
spring.application.name: 애플리케이션 이름을 설정 (서비스 간 로깅, 트레이싱 시 유용)spring:
profiles:
active: dev # 활성화할 프로파일
spring.profiles.active: 활성화할 프로파일 지정 (application-dev.yml, application-prod.yml 등과 함께 사용)spring.profiles.include: 여러 프로파일을 동시에 포함server:
port: 8080 # 서버 포트 지정
servlet:
context-path: /api # 애플리케이션 기본 URL 경로
server.port: 서버 포트 번호 설정server.servlet.context-path: 애플리케이션의 기본 URL 경로 설정spring.datasource)spring:
datasource:
url: jdbc:mysql://localhost:3306/mydb
username: root
password: secret
driver-class-name: com.mysql.cj.jdbc.Driver
spring.datasource.url: 데이터베이스 연결 URLspring.datasource.username: 데이터베이스 사용자 이름spring.datasource.password: 데이터베이스 비밀번호spring.datasource.driver-class-name: 데이터베이스 드라이버 클래스 이름spring.jpa)spring:
jpa:
hibernate:
ddl-auto: update
show-sql: true
properties:
hibernate.format_sql: true
spring.jpa.hibernate.ddl-auto: 테이블 생성 전략 (update, create, none 등)spring.jpa.show-sql: SQL 쿼리 로그 출력 여부hibernate.format_sql: SQL 포맷 정리spring.redis)spring:
redis:
host: localhost
port: 6379
spring.redis.host: Redis 서버 주소spring.redis.port: Redis 포트 번호spring.cache)spring:
cache:
type: redis
spring.cache.type: 캐시 유형 (예: none, simple, redis 등)logging)logging:
level:
root: INFO
com.example: DEBUG
logging.level.root: 전체 로그 레벨 설정 (DEBUG, INFO, WARN, ERROR)logging.level.[패키지명]: 특정 패키지의 로그 레벨 설정spring.messages)spring:
messages:
basename: messages
encoding: UTF-8
spring.messages.basename: 메시지 번들 파일 (예: messages.properties)spring.messages.encoding: 인코딩 설정spring.servlet.multipart)spring:
servlet:
multipart:
enabled: true
max-file-size: 10MB
max-request-size: 50MB
spring.servlet.multipart.enabled: 파일 업로드 활성화 여부spring.servlet.multipart.max-file-size: 최대 파일 크기spring.servlet.multipart.max-request-size: 요청당 최대 크기spring.mail)spring:
mail:
host: smtp.gmail.com
port: 587
username: myemail@gmail.com
password: mypassword
properties:
mail.smtp.auth: true
mail.smtp.starttls.enable: true
spring.security)spring:
security:
user:
name: admin
password: secret
spring.security.user.name: 기본 사용자 이름spring.security.user.password: 기본 사용자 비밀번호spring.cloud.config)spring:
cloud:
config:
uri: http://config-server:8888
fail-fast: true
| 카테고리 | 설정 키워드 | 설명 |
|---|---|---|
| 애플리케이션 | spring.application.name | 애플리케이션 이름 설정 |
| 프로파일 | spring.profiles.active | 활성화할 프로파일 지정 |
| 서버 | server.port | 서버 포트 설정 |
| 데이터베이스 | spring.datasource.url | DB 연결 URL |
| JPA | spring.jpa.hibernate.ddl-auto | 테이블 자동 생성 옵션 |
| Redis | spring.redis.host | Redis 서버 주소 |
| 캐시 | spring.cache.type | 캐시 유형 선택 |
| 로깅 | logging.level.root | 기본 로그 레벨 |
| 국제화 | spring.messages.basename | 다국어 메시지 파일 지정 |
| 파일 업로드 | spring.servlet.multipart.max-file-size | 최대 파일 크기 제한 |
| 이메일 | spring.mail.host | SMTP 서버 설정 |
| 보안 | spring.security.user.name | 기본 관리자 계정 설정 |
| Spring Cloud | spring.cloud.config.uri | Config 서버 URI |
spring: 키워드는 Spring Boot에서 미리 정해진 설정 값들을 관리하는 고정된 네임스페이스입니다.myapp: 같은 별도의 네임스페이스를 만들어 커스텀 설정을 추가할 수 있습니다.💡 추가 설정이 필요하면 말씀해 주세요! 😊