All Honey Tip

[Spring Error] Error starting ApplicationContext. To display the condition evaluation report re-run your application with ‘debug’ enabled.

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.


Spring Error
Error starting ApplicationContext. To display the condition evaluation report re-run your application with ‘debug’ enabled.

프로젝트 Build 시에 발생하는 에러입니다. Description을 확인해야합니다.


에러 메시지를 확인해보면 Failed to configure a DataSourceDB 연결 dependency가 존재하지만, 입력 정보가 없거나 잘못 되었기 때문에 발생합니다. 다른 메시지라면 아래 포스팅을 확인하세요!

[Spring Error] Web server failed to start. Port 8080 was already in use.

1. DB 정보 추가

application.properties나 application.yml 파일에 DB 정보를 추가하거나, 고쳐주면 됩니다.

application.properties
spring.datasource.url=jdbc:[Database]://localhost:8081/[Database스키마]
spring.datasource.username=[DB ID]
spring.datasource.password=[DB PW]
spring.datasource.driver-class-name=[JDBC Driver]

application.yml
spring:
  datasource:
    url: jdbc:[Database]://localhost:8081/[Database 스키마]
    username: [DB ID]
    password: [DB PW]
    driver-class-name: [JDBC Driver]



2. @SpringBootApplication 어노테이션에 exclude 추가.

지금 당장은 DB를 사용할 일이 없다면, src/main/java에 있는 메인 메서드의 @SpringBootApplication 어노테이션을 아래처럼 변경해주면 됩니다.

@SpringBootApplication(exclude= DataSourceAutoConfiguration.class)
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.



3. H2 Database 의존성 추가.

build.gradle의 dependencies에 아래 코드를 추가하고 reload하세요 ! (코끼리모양)

dependencies {
	runtimeOnly 'com.h2database:h2'
}

– 빌드 성공
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-11-08T14:10:11.779+09:00 ERROR 8440 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

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


종료 코드 0(으)로 완료된 프로세스