본문 바로가기
IT_Developers/JAVA

Spring Boot - "Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured." 오류

by 고코더 2022. 2. 4.

안녕하세요.

고코더 입니다.

 

스프링부트를 실행했는데 아래와 같은 오류가 발생했다고요?

 

오류메세지 

***************************
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).

 

 

원인, 해결방법

 

원인은 해당 mysql을 사용한다고 스프링부트에서 의존성이 되어 있지만 막상 데이터베이스를 접속하는 소스가 생성되지 않아서입니다. 아직 데이터베이스 연결을 하고 싶지 않으시다면 해당 부분을 삭제해서 다시 실행하거나

runtimeOnly 'mysql:mysql-connector-java'

 

"application.properties" 파일을 열어서 자신의 데이터베이스 연결을 기입하시면 됩니다.

# DataSource

spring.datasource.url=jdbc:mysql://접속주소
spring.datasource.username=ID
spring.datasource.password=패스워드
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

댓글