***************************
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
'Web > Spring' 카테고리의 다른 글
[Maven] 최초 build시 잡아야 하는 configuration (0) | 2021.11.07 |
---|---|
[Test] 실제 DB로 @DataJpaTest 돌리면 뜨는 "Failed to replace DataSource with an embedded database for tests" 에러 (0) | 2021.11.06 |
[Swagger] Swagger2 2.xx 버전오류 (0) | 2021.11.02 |
[Spring] OXM, 서비스 추상화, 빈 애노테이션, @Import, @Profile, @Enable* (0) | 2021.10.29 |
[Spring] 프록시, AOP, 트랜잭션 (0) | 2021.10.29 |
댓글