본문 바로가기

ErrorLog

[Spring Boot] 실행시 에러 Failed to configure a DataSource: 'url' attribute

# 문제발생

 

스프링부트 프로젝트 실행시 (Spring boot Dashboard > run) JDBC url 에러가 발생했다.

 

에러메시지

ex)

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

 

 

 

# 해결과정

 

1.

에러 중 Description 에 Failed to configure DataSource: 'url' attribute 로 나타나 

DB 접속정보를 다시보고 또 보았고, 이전에 되던 소스와 비교해도 동일했다.

해당부분에는 문제가 없다는 것을 확인.

 

2. 

Action 중 no profiles are currently active 구문을 살펴 보았다.

application.yaml  파일의 activate 를 확인해보았는데 local 로 되어 있었고 

application.yaml
(좌) application.yaml                                                                                (우) app-config.properties

app-config.properties 파일의 spring.active.profile 도 local 로 되어있음을 확인.

 

무엇이 문제일까?

 

3.

위의 두 파일은 선언만 해준 것이지, 실제 값이 셋팅되었는지는 알 수 없다. 

그래서 vscode 처음 실행할 때 로드되는 파일인 launch.json 파일의 args 을 보았다.  

args 구문에 active 구문이 없었다..!

 

그래서 구글링 후 추가...

 

1) spring boot active profile vscode 구글링 

2) launch.json 파일 > configurations >  아래  vmArgs 구문 추가 

"vmArgs": [
        "-Dspring.profiles.active=local",
      ],

 

 

#결과화면

 

args 추가 후 서버 정상 가동 됨 

 

Reference Site 명시 

ex) 참고한 사이트 : https://thinkub.github.io/2020/03/04/VSCode%EB%A1%9C%20Spring%20Boot%20%EC%82%AC%EC%9A%A9%EC%8B%9C%20profile%EC%84%A4%EC%A0%95/