Spring Boot Test DB 분리
H2
pom.xml 설정
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>application.yml 설정
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/{db명}
username: {username}
password: {password}
driver-class-name: com.mysql.jdbc.Driver
jpa:
show-sql: true
hibernate:
ddl-auto: create # 테스트용 DB 생성(실제 운영시 동일하게 사용하면, 애플리케이션 재기동시마다 삭제됨)Test 파일 설정
참고
Last updated