코딩과 결혼합니다

Failed to configure a DataSource 에러와 원인과 해결 방법 본문

청첩장/결혼식장 : 코린이의 저장소

Failed to configure a DataSource 에러와 원인과 해결 방법

코딩러버 2023. 8. 5. 15:58
728x90
ERROR 13264 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

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

Reason: Failed to determine a suitable driver class


Action:

Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

시도 : 오류를 해결하기 위해 구글에 검색해 보았다. 참고한 레퍼런스 https://7942yongdae.tistory.com/128

 

원인 : Database에 연결할 때 필요한 정보가 없기 때문이다. 주로 스프링 프레임워크를 이용해 프로젝트를 구성하는 초기에 발생하는 문제이다.

 

방법 : 프로젝트 전반에 필요한 환경 설정을 해준다.

spring.datasource.url=jdbc:[Database]://localhost:3306/[Database스키마]
spring.datasource.username=[DB 아이디]
spring.datasource.password=[DB 비밀번호]
spring.datasource.driver-class-name=[JDBC 드라이버]

나는 MySQL을 쓸 거라서 build.gradle에 라이브러리로 추가해 주었다. + 하이버네이트도 설정!

결과

오류가 사라지고 잘 실행된다.