Study/소소한 팁
[Spring Boot Error] Spring Boot 최초 실행 시 Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. 해결 방법
momong'-'
2023. 4. 25. 15:13
에러 메세지
***************************
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).
오류 원인
데이터 소스 구성 실패
DB에 연결하려는데 필요한 정보가 없어서 생기는 초기에 발생하는 오류다.
또는 application.propertes 파일이나 application.yml 파일과 같은 설정 파일이 삭제되었거나 위치가 옮겨졌을 경우에도 발생된다.
해결방안
application.propertes 파일이나 application.yml 파일 둘 중 하나만 있으면 환경 요소의 값을 설정 할 수 있다.
application.properties
spring.datasource.url=jdbc:[Database]://localhost:3306/[Database스키마]
spring.datasource.username=[DB 아이디]
spring.datasource.password=[DB 비밀번호]
spring.datasource.driver-class-name=[JDBC 드라이버]
application.yml
spring:
datasource:
url: jdbc:[Database]://localhost:3306/[Database스키마]
username: [DB 아이디]
password: [DB 비밀번호]
driver-class-name: [JDBC 드라이버]