Code in Life
[springboot] Failed to configure a DataSource. 'url' attribute... 본문
환경 : Windows10 Pro
에러 :
***************************
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).
Run/Debug Configurations에서 Program arguments에 --debug를 넣어보고 bundle.gradle을 rebuild해봤으나 해결되지 않았다. 좀 더 찾아보다가 application.yml을 아래 처럼 설정해주니 해결되었다. 원인은 Spring initializr에서 MySQL Driver를 Dependencies에 추가했기 때문에 알아서 잡힐 줄 알았는데, driver-class-name을 별도로 추가해줘야 한다.
# MySQL
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/[DB스키마명]?serverTimezone=UTC&characterEncoding=UTF-8
username: [DB접속Id]
password: [DB접속Password]
# H2
spring:
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:tcp://localhost/~/[DB스키마명];
username: [DB접속id]
password: [DB접속password]
'에러 및 이슈' 카테고리의 다른 글
[Git] Can't automatically merge (0) | 2020.12.09 |
---|---|
[springboot] Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8) (0) | 2020.12.06 |
[Git] git pull 명령시 에러 (0) | 2020.12.06 |
[Git] git pull upstream master을 입력했을 때 에러 (0) | 2020.12.01 |
InteliJ에서 Github 연동 오류 (0) | 2020.11.30 |