Just Do IT!

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

개발 공부/Error

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

MOON달 2025. 3. 4. 11:50
728x90
반응형

 

실습을 위한 프로젝트 생성 중,

application.yaml 파일에서 SQL 설정을 해주었는데 아래와 같은 오류가 나왔다.

 

 

 

이는

에러가 발생하는 이유는 Database에 연결할 때 필요한 정보가 없기 때문이다.

 

그런데 나는 제대로 작성했는데 왜 안되는지 고민했는데,

아주 사소한 부분이지만 중요한 부분을 수정해야 했었다.

 

spring:
  jpa:
    show-sql: true
    properties:
      format_sql: true
      dialect: org.hibernate.dialect.MySQLDialect
    hibernate:
      ddl-auto: validate
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/user
    username: 
    password:

 

 

이렇게 간단한 부분이었는데,

tab을 제대로 안한 내 잘못이었다.

 

들여쓰기로 계층을 구분하는데, jpa와 datasource가 같은 계층으로 되어야 제대로 작동함을 알 수 있었다.

이런 걸 잘 생각하고 환경 설정을 해야겠다.

728x90