인프런에서 스프링 공부 중 스프링 부트 프로젝트를 설치하고 인텔리제이에서 오픈했을 때 아래와 같은 에러가 발생했었다.
아래는 에러 메세지 일부
A problem occurred configuring root project 'core'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.1.3.
Required by:
project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.1.3
> No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.1.3 was found. The consumer was configured to find a library for use during runtime, compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.2.1' but:
- Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.1.3 declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 11
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '8.2.1')
오류메세지를 구글링해보니 Spring Boot 버전에 따라 Java 버전을 다르게 사용해야 하는 것을 확인했다.
현재 Spring Framework에서는 자바 17이상의 버전을 사용해야한다.(6.0.11 버전 기준)
또한 인프런에서 검색해보니 스프링 부트 3.x 버전에서는 Java 17이상 버전을, 2.x버전에서는 Java 11을 쓰면 될 것 같다.
스프링 부트 초심자 입장에서 계속해서 배워나가기 위해 최신 버전으로 공부해야겠다.
Reference
스프링 공식 문서
인프런 Q&A 참고
Jeongkuk Seo님 블로그
자바 11버전 vs 17버전
인텔리제이 자바 17버전