[1] 메인 클래스 실행 실패 (APPLICATION FAILED TO START)
***************************
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).
Class transformation time: 0.014812098s for 4898 classes or 3.0241114740710494E-6s per class
계속해서 데이터베이스 연결 정보가 없다면서 실행이 안됐다.
내가 아는대로라면 당연히 실행이 되고 설정한 포트로 들어가면 내 의도대로 떠야하는데..!
강의에서 DB 연결을 한 적도 없었다.
강의에서 H2나 다른 임베디드 DB 의존성이 이미 포함되어 있거나, application.yml(또는 application.properties)에 기본값이 설정되어 있었을 가능성이 있다는 생각이 들었다. 그치만 강의에서 알려주지 않고 넘어갈리가 없는데..?
강의를 본 다른 사람도 나와 같은 문제를 겪었는지 질문을 남겼는데 이번 회차 강의 후 다른 강의에서부터 DB를 추가하셨다고 한다.
DB 연결은 강의 순서를 따라가며 차차 할 생각이어서 DB 없이 실행하는 것을 목표로 해결방안을 찾아봤다.
해결방법은 아주 간단했다....🤯
dependencies {
// implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
// runtimeOnly 'mysql:mysql-connector-java'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
Spring Initializr에서 의존 라이브러리를 추가할 때 jpa를 추가해줬고, 후에 mysql을 사용할 것을 생각해 mysql 커넥터를 런타임 의존성으로 추가해놨다.
이 두 줄이 문제였다!!
주석 처리를 해버리니 실행이 잘 되었고 설정해두었던 포트를 들어가니 원하는대로 잘 나왔다.
초반부터 막혔지만 이렇게라도 알게 되었으니 다행이라고 생각한다...🥹
열심히 공부해야겠다!!
'SpringBoot 프로젝트 중 뜬 에러에 관해' 카테고리의 다른 글
카테고리 소개(?) (0) | 2025.03.21 |
---|