Error
[Spring] “Failed to Configure a DataSource” Error
나수비니
2023. 11. 5. 21:05
728x90
Problem
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
Cause
스프링 부트 auto-configuration이 클래스 패스에 추가된 디펜던시를 기반으로 빈을 자동으로 구성을 시도한다.
JPA 디펜던시 클래스 패스를 갖고있기 때문에, 스프링 부트는 자동으로 JPA 데이터 구조를 구성하려하지만 스프링 부트에게 auto-congifuration을 수행할 정보를 제공하지 않았기 때문임.
예를들면 MySQL과 같은 외부 데이터 베이스로 작업을 해야할 경우, JDBC 커넥터가 필요한데 이 연결 속성을 정의해주지 않았기 때문이다.
Solution
- application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/myDb
spring.datasource.username=user1
spring.datasource.password=pass
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
application.properties 내에 DB 연동 속성을 입력해주면 해결된다.