[Spring Boot] - Mysql 연동하기

chanyeong kim·2023년 2월 22일
0

Spring Boot

목록 보기
2/3

Spring boot 기반 프로젝트 진행하면서 만난 이슈 및 꿀팁 정리

프로젝트 환경 설정 후, MySQL DB 연동


기본적으로, MySQL에서 스키마 생성후, 스키마 이름 및 DB 관련 정보를 application.properties에 작성해주어야 한다.

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/{schema name}serverTimezone=Asia/Seoul&characterEncoding=UTF-8
spring.datasource.username= {계정명}
spring.datasource.password=	{비밀번호}	

# true 설정시 JPA 쿼리문은 확인할 수 있다.
spring.jpa.show-sql=true
 
# DDL(create, alter, drop) 정의시 DB의 고유 기능을 사용할 수 있다.
spring.jpa.hibernate.ddl-auto=create
 
# JPA의 구현체인 Hibernate가 동작하면서 발생한 SQL의 가독성을 높여준다.
spring.jpa.properties.hibernate.format_sql=true

🙂

0개의 댓글