Notice
Recent Posts
Recent Comments
Link
나의 GitHub Contribution 그래프
Loading data ...
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

Code in Life

[springboot] Failed to configure a DataSource. 'url' attribute... 본문

에러 및 이슈

[springboot] Failed to configure a DataSource. 'url' attribute...

퓨끼 2020. 12. 6. 11:28

환경 : 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]
    

 

Comments