나는 mysql을 쓴다.
1. 내가 쓸 스키마를 확인한다.
나는 abcd를 쓸거다.
2. build.gradle에 mysql관련 있는지 확인
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j' // 여기
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
3. application.yml 파일에 다음과 같이 작성한다.
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:[사용 포트]/[스키마 명]
username: [ 실제 username ]
password: [ 실제 password ]
내 예시는 이렇다.
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql:localhost:3306/abcd
username: user
password: 123456