Spring 공식 홈페이지( https://start.spring.io/ )를 통해 프로젝트(Gradle - Groovy / Spring boot 3.2.4 / Package: Jar / Java 17)를 생성한 후,
IntelliJ에서 해당 프로젝트를 빌드했는데 오류 발생
※ 오류 내용
A problem occurred configuring root project 'hello-spring'.`
> Could not resolve all files for configuration ':classpath'.
> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.1.
Required by:
project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.0.1
> No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.0.1 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.6' but:
- Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.1 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
한마디로 프로젝트에서 지원하는 자바 버전과 현재 IntelliJ에 설정된 자바 버전이 맞지 않다는 소리
아래 두가지 설정을 변경하면 해결될 거임
참고로 스프링부트3.x 는 자바17부터 지원하기 때문에 스프링부트 2.x는 자바11을 이용해야 함
1. 프로젝트 sdk 버전 설정
Project Settings(Ctrl+Alt+Shift+S) > Project - SDK => jdk 17
2. Gradle JVM 버전 설정
File > Settings > Build, Execute, Deployment > Build Tools > Gradle - Gradle JVM => jdk 17