Home
Java
url attribute is not specified and no embedded datasource could be configured
devfoxstar
devfoxstar
July 18, 2022
1 min

Table Of Contents

01
원인
02
해결 방안 - 첫 번째
03
해결 방안 - 두 번째

원인

스프링부트 프로젝트를 처음 구성하고 실행하면 아래와 같은 에러를 만날 수 있습니다.
스프링부트에서는 자동으로 디비 연결을 실행하는데, 디비 설정 정보가 없으면 나는 오류입니다.

***************************
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);
    }

}

Tags

#Java#DataSource#Error

Related Posts

Java - Record class (불변 데이터 객체 만들기)
June 11, 2024
1 min
© 2024, All Rights Reserved.

Quick Links

About Me

Media