본문 바로가기
카테고리 없음

[에러 해결] Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

by 문자메일 2023. 8. 8.

에러 문구 : Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

 

 

에러 원인 : 프로젝트 생성시 spring-data-jpa 의존성을 추가하면, 이 의존성이 application.yml 설정을 읽어서 DB 설정을 자동으로 해준다.

그런데 yml에 DB에 url을 지정되어 있지 않아서 DB에 연결할 수 없다고 발생한 에러이다.

 

implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

 

에러 해결 : 아래처럼 yml 파일에 DB 관련 정보들을 추가해 주면  된다.

spring:
  jpa:
    hibernate:
      ddl-auto: update
    show-sql: true
    properties:
      hibernate:
        format_sql: true
  datasource:
    hikari:
      maximum-pool-size: 4
    url: jdbc:mysql://127.0.0.1:13306?zeroDateTimeBehavior=convertToNull&characterEncoding=UTF-8&serverTimezone=Asia/Seoul
    username: root
    password: root
    driver-class-name: com.mysql.cj.jdbc.Driver

댓글