🔻Back-End/Spring
[Spring] 스프링 프로젝트를 DB와 연결하기
_니지
2022. 10. 29. 20:17
DB를 연결하지 않고 서버를 실행하면
DB를 연결해주라는 오류 문구가 나오게 된다
❗연결 방법
application.properties에서 설정을 통해 DB를 연결할 수 있다.
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=비밀번호
spring.datasource.url=jdbc:mysql://localhost:3306/[스키마(데이터베이스)이름]?characterEncoding=UTF-8&serverTimezone=UTC
application.yml이라면 아래의 포스팅에서 확인할 수 있다.
https://radiant515.tistory.com/352
[Spring] MySQL, MariaDB, H2 DB 연결하는 application.yml 설정
프로젝트와 DB를 연결할 때 yml에서 어떤 DB를 쓸 것인지 명시해주어야 한다각 DB에 따라서 드라이버 이름과 url이 다르기 때문에 나누어 작성해두었다! ❗MySQLspring: datasource: driver-class-name: com.mysql.
radiant515.tistory.com
728x90
반응형