[스프링] SpringBoot 3.0.x부터는 Java 17을 사용해야 한다

sky·2023년 6월 19일
0

Spring

목록 보기
1/1

약 1년 만에 스프링을 다시 공부하려고 Intellij에서 스프링부트로 만든 프로젝트를 열자마자 이런 오류가 날 반겼다.

> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.0.
     Required by:
         project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.0.0
      > No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.0.0 was found. The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.5.1' but:
          - Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.0 declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares an API of a component compatible with Java 17 and the consumer needed a runtime of a component compatible with Java 11
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '7.5.1')

이것보다 훨씬 길었는데 'no matching variant ...'로 검색했고 원인은 다음과 같았다.

# 원인

스프링 부트가 3.0.x 버전으로 업그레이드되면서 Java 11이 아닌 17을 사용한다고 한다. 실제로 오류 문구 중에 이런 내용이 떡하니 있다.

참고로 업그레이드로 인해 javax 패키지 중 몇개 이름을 javax→jakarta로도 변경해야 한다.

Incompatible because this component declares an API of a component compatible with Java 17

# 해결 방법

Preferences(환경설정) → Build,Execution,Deployment → Build Tools → Gradle → Gradle JVM을 Java 17로 변경해주면 된다.

참고한 stackoverflow 글

profile
우당탕탕 개발일기

0개의 댓글