본문 바로가기
프로그래밍/SPRING

Spring boot - Failed to determine a suitable driver class

by 애플 로그 2022. 5. 20.
반응형

Spring boot - Failed to determine a suitable driver class

 

1. 에러 내용 : 

2022-05-20 14:31:06.670 DEBUG 270240 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   
:Application failed to start due to an exception

org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException
: Failed to determine a suitable driver class

-------중략------

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

 

 

2. 내용

pom.xml 또는 gradle에 DB관련 설정이 있지만,

나의 경우는 gradle을 사용하고 아래 설정이 있었다.

    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

application.yml 파일에 테이터베이스 값을 설정하려고 시도하지만 데이터베이스 값이 없어서 나는 에러이다.

 

3. 해결

방법1. DB안 쓸꺼면, 2번 내용의 DB 관련 Dependency를 지워라.

 

방법2. DB 쓸꺼면,

application.yml 파일에 DB관련 정보를 아래와 같이 작성 해라

spring:
  datasource:
    driver-class-name:
    url:
    username:
    password:

 

방법3. 어노테이션 DataSourceAutoConfiguration 제외 추가

springBoot Application class에 아래와 같이 DB사용 안한다고 추가한다.

 

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
public class RestfulWebServiceApplication {

	public static void main(String[] args) {
		SpringApplication.run(RestfulWebServiceApplication.class, args);
	}

}

 

댓글