Spring boot 빌드 설정 에러 해결방법

아빠는 외계연·2022년 9월 10일
0

Spring Boot

목록 보기
2/4
post-thumbnail

빌드 에러 발생

첫번째 에러

Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain

에러가 발생하였다.

참고 블로그

해당 블로그의 도움을 받아 gradle/wrapper 디렉토리 내부에 gradle-wrapper.jar파일이 없어서 생기는 에러라는 것을 깨달았다.

해결 방법

  1. gradle 설치
  2. gradle wrapper 명령어 실행 → gradle-wrapper.jar파일 생성!

두번째 에러

Execution failed for task ':compileJava'.

./gradlew clean build                                                                              ✔  15:05:52> Task :compileQuerydsl
Note: Running JPAAnnotationProcessor
Note: Serializing Supertypes
Note: Generating com.example.Estate_Twin.util.QBaseTimeEntity for [com.example.Estate_Twin.util.BaseTimeEntity]
Note: Serializing Entity types
Note: Generating com.example.Estate_Twin.house.domain.entity.QOfficetel for [com.example.Estate_Twin.house.domain.entity.Officetel]
Note: Generating com.example.Estate_Twin.asset.data.entity.QAsset for [com.example.Estate_Twin.asset.data.entity.Asset]
Note: Generating com.example.Estate_Twin.checklist.data.entity.QCheckList for [com.example.Estate_Twin.checklist.data.entity.CheckList]
Note: Generating com.example.Estate_Twin.media.domain.entity.QMedia for [com.example.Estate_Twin.media.domain.entity.Media]
Note: Generating com.example.Estate_Twin.contractstate.domain.entity.QContractState for [com.example.Estate_Twin.contractstate.domain.entity.ContractState]
Note: Generating com.example.Estate_Twin.estate.domain.entity.QDipEstate for [com.example.Estate_Twin.estate.domain.entity.DipEstate]
Note: Generating com.example.Estate_Twin.user.domain.entity.QUser for [com.example.Estate_Twin.user.domain.entity.User]
Note: Generating com.example.Estate_Twin.house.domain.entity.QHouse for [com.example.Estate_Twin.house.domain.entity.House]
Note: Generating com.example.Estate_Twin.estate.domain.entity.QEstate for [com.example.Estate_Twin.estate.domain.entity.Estate]
Note: Generating com.example.Estate_Twin.address.data.entity.QAddress for [com.example.Estate_Twin.address.data.entity.Address]
Note: Generating com.example.Estate_Twin.user.domain.entity.QBroker for [com.example.Estate_Twin.user.domain.entity.Broker]
Note: Generating com.example.Estate_Twin.estate.domain.entity.QEstateHit for [com.example.Estate_Twin.estate.domain.entity.EstateHit]
Note: Running JPAAnnotationProcessor
Note: Running JPAAnnotationProcessor

> Task :compileJava
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
1 actionable task: 1 executed

→ 자바 버전이 안맞아서 생기는 오류였음.

내 자바 버전은 18버전인데 프로젝트는 8버전으로 설정되어있었기 때문

프로젝트 버전 설정

  1. Project Settings → Project : 1.8로 설정
  1. Project Settings → Modules : 1.8로 설정
  1. Project Settings → SDKs 에 1.8이 깔려있는지 확인

⇒ 요렇게 설정을 완료하면 1.8버전으로 되어있음

  1. Preferences → Build,Execution,Deployment → Compiler → Java Compiler : 1.8로 설정
  1. gradle 사용중이라면 build.gradle 파일에서 sourceCompatibility : 1.8로 설정

이렇게 까지 설정을 했을 때 intellij ide에서는 빌드가 잘 되었지만 터미널에서는 되지 않았다.

따라서 내 자바 버전과 프로젝트 버전이 맞지 않아 생기는 에러라고 판단하였다.

버전을 확인해 보았더니 역시 18버전으로 인식되어 있었고, 8버전으로 변경을 진행하였다.


그 후 빌드를 진행하면!

성공적으로 진행된다.

profile
Backend Developer

0개의 댓글