IntelliJ Gradle Project Error) Could not resolve all files for configuration ':classpath'. Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.2.

반응형

 

Error

인텔리제이로 그레이들 프로젝트를 불러왔는데 다음과 같은 에러가 발생하였다.

A problem occurred configuring root project 'example'.
> 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 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.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 11
              - 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 11)
                  - 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')
          - Variant 'mavenOptionalApiElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional: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 11
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
          - Variant 'mavenOptionalRuntimeElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.0.2 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component compatible with Java 17 and the consumer needed a component compatible with Java 11
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
          - Variant 'runtimeElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.2 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component compatible with Java 17 and the consumer needed a component compatible with Java 11
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
          - Variant 'sourcesElements' 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 11)
                  - 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')

* 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.

해결 방법

결론부터 말하자면 이는 스프링 부트에서 요구하는 자바 버전이 낮아서 발생하는 문제이다.

 

방법1) 상위 버전의 자바 설치

스프링 부트 3.x 버전은 자바 버전 17을 요구하므로 17버전을 설치해주면 된다.

해당 포스팅에서는 오픈 JDK 17로 진행하였다. https://jdk.java.net/java-se-ri/17

 

Java Platform, Standard Edition 17 Reference Implementations

Java Platform, Standard Edition 17 Reference Implementations The official Reference Implementation for Java SE 17 (JSR 392) is based solely upon open-source code available from the JDK 17 Project in the OpenJDK Community. The binaries are available unde

jdk.java.net

 

다운로드 받은 파일을 Java가 설치되어있는 폴더에 넣어준다.

(보통 경로를 설치하지 않고 설치한 자바의 경로는 C:\Program Files\Java 이다.)

 

(인텔리제이에서) File - Settings

 

좌측 메뉴에서 Build, Execution, Deployment - Build Tools - Gradle

Gradle JVM - 자바 버전 17 선택

 

Build - Build Project

 

해당 프로젝트의 필요 라이브러리가 다운로드 된다.

 

문제 없이 빌드가 완료된 모습


2) 스프링 부트 버전 다운그레이드

혹은 스프링 부트의 버전을 2.x 버전으로 낮추면 된다.

스프링 부트의 버전은 spring.io 홈페이지에서 이니셜라이즈 페이지에서 대략적으로 확인이 가능하다.

 

build.grade 파일에서 해당 자바의 버전을 2버전대로 낮추어 리빌딩하면 된다.

반응형