🍃 𝗦𝗽𝗿𝗶𝗻𝗴 𝗕𝗼𝗼𝘁

[SpringBoot] 프로젝트 생성 후 실행 에러 (Error creating bean with name 'dataSource' defined in class path resource)

비타민찌 2022. 7. 11. 12:53
728x90

상황 : 프로젝트 생성 후 바로 실행 했는데 다음과 같은 에러 남.

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]: bean instantiation via factory method failed; nested exception is org.springframework.beans.beaninstantiationexception: failed to instantiate [com.zaxxer.hikari.hikaridatasource]: factory method 'datasource' threw exception; nested exception is java.lang.illegalstateexception: cannot load driver class: com.mysql.jdbc.driver

 

이유 : dataSource 문제. mysql 이나 mybatis등 디비 관련 설정을 추가했는데 build gradle이나 application.yml 에 설정을 제대로 해주지 않으면 발생한다.

 

해결 :

나의 경우 build.gradle에 요걸 빼먹어서 발생했다. 추가 후 실행하면 문제 해결!

dependencies {
    implementation 'mysql:mysql-connector-java'
    // 이하 생략
}

 

728x90