Spring Boot - test폴더 profile 분리

청포도봉봉이·2023년 3월 29일
0

Spring

목록 보기
12/32
post-thumbnail

Junit으로 실행시키는 테스트 폴더와 main폴더에 대한 profile을 분리하고 싶었다.
main : local
test : test 이런식으로?

기존 application.yml

spring:
  profiles:
    active: local
  datasource:
    url: jdbc:h2:tcp://localhost/~/querydsl
    username: sa
    password:
    driver-class-name: org.h2.Driver

  jpa:
    hibernate:
      ddl-auto: create #application 시작 될때 table을 생성해준다.
    properties:
      hibernate:
#      show_sql: true
        format_sql: true
#        use_sql_comments: true #쿼리가 보일때 alias가 나오게 표출 - 같은 테이블을


logging.level:
  org.hibernate.SQL: debug  #logger
# org.hibernate.type: trace #System.out
  • spring.profiles : local로 설정한다.

  • test 폴더 밑에 resources/application.yml 파일을 복붙한다.

test쪽 application.yml

spring:
  profiles:
    active: test
  datasource:
    url: jdbc:h2:tcp://localhost/~/querydsl
    username: sa
    password:
    driver-class-name: org.h2.Driver

  jpa:
    hibernate:
      ddl-auto: create #application 시작 될때 table을 생성해준다.
    properties:
      hibernate:
#      show_sql: true
        format_sql: true
#        use_sql_comments: true #쿼리가 보일때 alias가 나오게 표출 - 같은 테이블을


logging.level:
  org.hibernate.SQL: debug  #logger
# org.hibernate.type: trace #System.out
  • spring.profiles : test로 설정한다.

이렇게 하면 junit test를 할땐 profile을 test로 두고 실행하게 된다.

profile
자존감 낮아질 시간에 열심히 공부하고 커밋하자😊😊

0개의 댓글