스프링부트 프로젝트를 처음 구성하고 실행하면 아래와 같은 에러를 만날 수 있습니다.
스프링부트에서는 자동으로 디비 연결을 실행하는데, 디비 설정 정보가 없으면 나는 오류입니다.
*************************** 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). Process finished with exit code 0
application.properties
또는 application.yml
파일에 디비 정보를 설정해 주면 됩니다.
#DataSource - application.properties spring.datasource.url= spring.datasource.username= spring.datasource.password= spring.datasource.driver-class-name=
#DataSource - application.yml spring: datasource: url: username: password: driver-class-name:
당장 디비 연결이 필요없는 프로젝트라면, Application이 실행될 때 예외처리를 할 수 있습니다.
#SpringBaseApplication.java package com.devfoxstar.springbase; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; @SpringBootApplication(exclude = DataSourceAutoConfiguration.class) public class SpringBaseApplication { public static void main(String[] args) { SpringApplication.run(SpringBaseApplication.class, args); } }