본문 바로가기
각종 에러

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

by 쿠키오빠 2025. 5. 20.
반응형

개인 프로젝트를 하나 만들기 위해 의존성만 주입하고 실행해보니 아래와 같은 에러 발생.

'o.s.b.d.LoggingFailureAnalysisReporter '

 

 

추가한 의존성은 아래와 같다.

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compileOnly 'org.projectlombok:lombok'
    runtimeOnly 'com.mysql:mysql-connector-j'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

 


<원인>

application.properties 파일을 yml로 변경하였는데, 데이터베이스에 연결할 때 필요한 값을  yml 파일에 작성하지 않아서 생긴 문제. (DB 관련 url, driver, 계정 정보 등)

 

 

프로젝트 생성 후 최초의 이렇게 적혀 있었다.

spring.application.name=cookieblog

 


<해결>

아래와 같이 데이터 베이스 관련 설정값을 작성하였다.

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/cookieblog
    username: cookieblog
    password: cookieblog

 

 

이후, 실행하니 잘 동작한다.

반응형