Failed to configure a DataSource 에러

5714 단어 SpringSpring

Failed to configure a DataSource

스프링(부트) 프레임워크를 사용하다 발생한 에러,
발생한 이유는 Database에 연결에 필요한 정보가 없기 때문.

***************************
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).

찾아보니 프로젝트를 구성하는 초기나, application.properties파일이나 application.yml파일의 삭제 혹은 옮김으로서 자주 발생할 수 있는 에러라고 함.

해결방법은 스프링 프로젝트 전반에 필요한 정보를 남아내는, application.properties파일 혹은 application.yml파일에 데이터베이스 환경요소를 등록하여 연동시키면 된다.

application.properties

spring.datasource.url=jdbc:[Database]://localhost:3306/[Database스키마] 
spring.datasource.username=[DB 아이디] 
spring.datasource.password=[DB 비밀번호] 
spring.datasource.driver-class-name=[JDBC 드라이버]

application.yml

spring: 
  datasource: 
    url: jdbc:[Database]://localhost:3306/[Database스키마] 
    username: [DB 아이디] 
    password: [DB 비밀번호] 
    driver-class-name: [JDBC 드라이버]
  • 참고로 이런 어플리케이션 설정은 yml로 작성하는 추세인것 같다.

좋은 웹페이지 즐겨찾기