MySQL로 DB 세팅하기

KIM YONG GU·2023년 10월 12일

SpringBoot

목록 보기
2/17

1. MySQL connector 의존성 추가

  • build.gradle에 추가
implementation 'com.mysql:mysql-connector-j:8.0.33'

build.gradle에서는 의존성(dependancy) 등 다양한 라이브러리 초기값(?)을 부여할 수 있다.

2. application.properties에 DB 접속 정보 등록

spring.datasource.url:jdbc:mysql://localhost:3306/{db이름}?useUnicode=true&characterEncoding=utf8&autoReconnect=true&serverTimezone=Asia/Seoul
spring.datasource.driverClassName:com.mysql.cj.jdbc.Driver
spring.datasource.username:root
spring.datasource.password:

만약 사전 준비단계에서 포트 8080을 사용할수 있게 종료했는데도 문제가 발생한다면
위쪽에 한줄을 추가한다.

server.port=8081
spring.datasource.url:jdbc:mysql://localhost:3306/{db이름}?useUnicode=true&characterEncoding=utf8&autoReconnect=true&serverTimezone=Asia/Seoul
spring.datasource.driverClassName:com.mysql.cj.jdbc.Driver
spring.datasource.username:root
spring.datasource.password:

대부분의 어플리케이션 관련 설정은 application.properties에 추가한다.

profile
Engineer, Look Beyond the Code.

0개의 댓글