IntelliJ를 이용하여 SpringBoot 프로젝트를 Run했을때, 다음과 같은 오류가 발생하면서 실행이 되지 않는 경우가 발생하였습니다.
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
상세한 결과는 아래와 같습니다.
***************************
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).
저의 경우는 MariaDB를 데스크탑에 설치이후에 SpringBoot를 Running하니 발생하기 시작했습니다.
Database를 설치하면 IntelliJ에 JDBC Driver를 연결해주어야한다고 합니다.
IntelliJ에서는 application.properties에 다음과 같이 JDBC url을 추가해줍니다.
#mariadb
spring.datasource.driverClassName=org.mariadb.jdbc.Driver
spring.datasource.url=jdbc:mariadb://localhost:3306/test?characterEncoding=UTF-8&serverTimezone=UTC
spring.datasource.username=root (혹은 MariaDB 설치시 설정했던 사용자이름)
spring.datasource.password=MariaDB 설치시 생성했던 비밀번호
※ Mariadb를 다른 포트에 설치하셨으면 jdbc:mariadb://localhost에 다른포트번호를 적어줘야합니다.
※ mySql이나 Oracle등 다른 DB를 설치하셨으면 application.properties에 알맞은 url및 정보를 기재해주세요.
'Development > SpringBoot' 카테고리의 다른 글
스프링부트에서 다른패키지의 @RestController가 작동하지 않을경우 (1) | 2021.03.05 |
---|