[spring 오류] Failed to configure a DataSource

오잉·2023년 2월 6일
0

spring 오류

목록 보기
2/2

메시지

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

원인

Database에 연결하기 위해 필요한 정보가 없기 때문

해결

스프링은 Database 연결 설정 정보뿐만 아니라 프로젝트 전반에 필요한 환경 설정 값을 파일로 관리할 수 있다.

대표적인 환경 설정 파일

  • application.yml
  • application.properties

application.yml

spring:
  datasource:
    url: jdbc:[Database]://localhost:3306/[Database스키마]
    username: [DB 아이디]
    password: [DB 비밀번호]
    driver-class-name: [JDBC 드라이버]

application.properties

spring.datasource.url=jdbc:[Database]://localhost:3306/[Database스키마]
spring.datasource.username=[DB 아이디]
spring.datasource.password=[DB 비밀번호]
spring.datasource.driver-class-name=[JDBC 드라이버]
profile
오잉이라네 오잉이라네 오잉이라네 ~

0개의 댓글