본문 바로가기
Java Web/Spring Boot

[Spring Boot] yml 파일

by 스응 2023. 4. 14.
728x90
728x90

#  yml 파일의 특징

  -  엄격한 문법 규칙

      · 하위 요소를 입력할 때에는 스페이스 2번 (TAP 키 == 스페이스 2번)

      · 콜론(:) 이전에는 스페이스 X

      · 콜론(:) 다음에는 스페이스 1번

      · 단, 경로 지정 시의 :는 스페이스 X

  - 하이픈(-)을 통해 Array임을 나타냄

  - properties 파일보다 반복적인 부분이 적음

  - 주석 : #

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
server:
  port: 8080 # 포트 번호
  servlet: 
    encoding:
      charset: utf-8 # 인코딩 표준
      force: true
      
# 첫 줄 시작 : 루트 로드
spring: 
  mvc:
    view: # JSP 사용 설정
      prefix: /WEB-INF/view/ # jsp 파일 경로
      suffix: .jsp # 확장자
  datasource: # DB 설정
    url: jdbc:h2:mem:testdb;MODE=MySQL
    driver-class-name: org.h2.Driver
    username: sa # 유저 이름
    password: # 비밀번호 (비워두면 비밀번호 X)
  sql: 
    init: # 초기 sql 파일 읽기 
      schema-locations: # 스키마 (테이블 생성 등)
      - classpath:db/table.sql # 콜론 띄어쓰기 X, db 폴더 아래 table.sql 파일 읽으라는 뜻
      data-locations: # 샘플 데이터
      - classpath:db/data.sql
  h2: # H2 Database 설정
    console: 
      enabled: true
  output: 
    ansi: # 쿼리문 표준
      enabled: always
 
mybatis:
  mapper-locations:         # **.xml : 해당 경로 아래 모든 xml 파일
  - classpath:mapper/**.xml # classpath는 src/main/resources/ 아래부터 시작
  configuration:
    map-underscore-to-camel-casetrue # DB의 underscore(snake case) 방식을 Java의 camel case 방식과 매핑
cs
320x100
반응형

댓글