[SpringBoot] Error creating bean with name 'dataSource' defined in class path resource 에러

liljoon·2023년 11월 24일
0
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception with message: Failed to load driver class org.h2.Driver in either of HikariConfig class loader or Thread context classloader

Spring Data Jpa를 사용 후 실행 시 에러 발생

찾아보니 크게 두가지의 문제점이 있다.
h2 db의 기준이다.

  1. 실수로 dependency에 추가하지 않았을 경우
    build.gradle 확인
runtimeOnly 'com.h2database:h2'
  1. driverClassName 지정 안했을 시

application.properties에 추가

spring.datasource.driverClassName=org.h2.Driver

0개의 댓글