spring boot와 mysql을 연동하기 위해 다음과 같이 설정했다.
application.yml
server:
port:9059
spring:
jpa:
hibernate:
ddl-auto: create-drop
show-sql: true
database: mysql
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/school_management?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Seoul
username: ****
password: ****
build.gradle
dependencies {
implementation("$boot:spring-boot-starter-data-jpa")
runtimeOnly("mysql:mysql-connector-java")
}
application.yml과 build.gradle을 위와 같이 실행하고 테스트를 돌렸더니
다음과 같이 Failed to replace DataSource with an embedded database for tests. 에러가 나왔다.
이를 해결하기 위해 @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
태그를 붙여주었다.
자세한 내용은 https://charliezip.tistory.com/21에 기록되어있다.
이후에 다시 Test를 돌려보니