본문 바로가기
Web/Spring

[Custom datasource] hikary.jdbc-url 쓰다가 Failed to configure a DataSource: 'url' 발생

by 정고정 2021. 11. 6.
반응형
***************************
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

datasource를 hikari로 설정했을 때 발생하는 오류다.

 

에러가 발생했을 때의 application.properties

spring.datasource.hikari.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.hikari.jdbc-url=jdbc:mysql://localhost:3306/${스키마이름}?serverTimezone=UTC&useUniCode=yes&characterEncoding=UTF-8
spring.datasource.hikari.username=${아이디}
spring.datasource.hikari.password=${비밀번호}

 

hikari로 명시해주지 말고 그냥 잡아주면 된다.

spring이 업데이트 되면서 어차피 기본적으로 hikari pool을 쓰도록 되어 있다. 따로 설정을 잡아준다면 몰라도 기본적인 datasource는 제대로 잡아주자.  

 

수정한 application.properties 

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/${스키마이름}?serverTimezone=UTC&useUniCode=yes&characterEncoding=UTF-8
spring.datasource.username=${아이디}
spring.datasource.password=${비밀번호}

 

그런데 예전에 gradle로 진행하던 프로젝트 보니까 datasource를 다 히카리로 퉁쳤던데 그때는 왜 됐는지 모르겠다... 

아마 새로 진행하던 프로젝트랑 dependency가 많이 다른데다가 설정파일도 이것저것 붙여서 그런가 보다. 

 

 

참고

발생했던 custom datasource 관련 부분으로 링크 걸어뒀다. 

 

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto.data-access

 

Spring Boot Reference Documentation

This section goes into more detail about how you should use Spring Boot. It covers topics such as build systems, auto-configuration, and how to run your applications. We also cover some Spring Boot best practices. Although there is nothing particularly spe

docs.spring.io

 

반응형

댓글