오류 및 해결/Spring
[Spring Boot] DB 연동 오류 해결 : Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
minNa2
2025. 2. 17. 16:35
[ 문제 ]
프로젝트 구성 중 DB를 연동하지 않아 실행 시 아래와 같은 오류 발생
***************************
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).
Process finished with exit code 0
[ 해결법 ]
1. DB 연동
application.yml 파일에 DB 연동 정보 입력
######### 기본 설정 #########
spring:
datasource:
url: #[Database]://localhost:3306/[Database 스키마]#
username: #[DB 아이디]#
password: #[DB password]#
driver-class-name: #[JDBC 드라이버]#
2. 옵션 추가
DB 접속 정보가 없을 시 Application.java 파일에 exclude 옵션 추가
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
정상 작동 확인
반응형