Spring Boot 버전에 따른 Java 버전

Jeongkuk Seo
sjk5766
Published in
6 min readJan 27, 2023

스프링 부트 공식 홈페이지에 가면 아래와 같이 스프링 부트 프로젝트를 편하게 만들어주는 start.spring.io를 소개하고 있다.

원하는 옵션을 설정하고 Generate 버튼을 누르면 압축된 zip 파일을 다운로드 받는데 이를 프로젝트 폴더에 넣으면 된다. 문제는 내 경우 아래와 같은 에러가 발생했다.

A problem occurred configuring root project 'demo'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.2.
Required by:
project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.0.2
> No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.0.2 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.6' but:
- Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.2 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 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
- Variant 'javadocElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.2 declares a runtime of a component, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '7.6')

아래는 전체 에러의 일부를 캡쳐한 화면이다.

약간의 구글링을 통해 Spring boot 버전에 따라 java 버전을 달리 사용해야 하는 것을 알았다.

공식 Document 발췌

스프링 부트 3.x 버전에선 Java 17 이상 버전을, 2.x 버전에선 자바 11을 쓰면 될 것 같다.

구글링을 통해 인프런 답변 확인

내 경우 3.x 버전의 스프링 부트가 필요하기 때문에 아래 옵션으로 프로젝트 구조를 생성했다.

이제 IntelliJ로 해당 프로젝트를 열고 Project Structure 버튼을 누른다.

Project 탭에서 SDK와 Language Level을 17 버전에 맞게 세팅한다.

Modules 탭에서 Language Level을 세팅한다.

SDKs 탭에서 JDK home path를 버전에 맞게 세팅한다.

[File] — [Settings] 버튼을 누르고 Build, Execution, Deployment의 Gradle 탭에서 JVM 설정을 버전에 맞게 세팅한다.

모든 설정을 완료한 뒤 실행하면 정상적으로 실행됨을 확인할 수 있다.

레퍼런스

--

--