Lined Notebook

Spring Boot 3.x 버전 실행시 오류 (with: IntelliJ)

by yjym33
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.1.4.
     Required by:
         project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.1.4
      > No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.1.4 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, 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.4 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 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.2.1')
          - Variant 'javadocElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.1.4 declares a component for use during runtime, 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 '8.2.1')
          - Variant 'mavenOptionalApiElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.1.4 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 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.2.1')
          - Variant 'mavenOptionalRuntimeElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.1.4 declares a library for use during runtime, 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 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.2.1')
          - Variant 'runtimeElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.1.4 declares a library for use during runtime, 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 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.2.1')
          - Variant 'sourcesElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.1.4 declares a component for use during runtime, 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 '8.2.1')

스프링 부트 3.0이 출시되면서 기존 Java8 또는 Java11을 사용하는 분들은 다음과 같은 오류를 만나게 됩니다.

해당 오류의 내용은 Spring boot Gradle의 플러그인 버전 3.14를 찾을수가 없다는 내용으로

해당 오류가 발생하는 이유는 Java 버전 문제 때문입니다.

 

스프링 3.0 부터는  Java 17부터 지원이 되기 떄문Java17 버전 이상을 사용해야 하기 때문입니다.

위의 오류를 해결하기 위해서는 다음과 같은 방식으로 확인후 Java 버전을 변경해주어야 합니다.

1. Java 버전 확인 (Java 17버전 이상인지 확인)

 

2. build.gradle

해당 프로젝트의 sourceCompatibility 가 17이상으로 되어있는지 확인해야 합니다.

 

3. IntelliJ 설정

이 프로젝트를 실행하는 IntelliJ가 프로젝트를 Java 17로 실행되어야 하기 떄문에 IntelliJ에서 다음과 같은 설정을 따라야 합니다.

 

3.1 Gradle Build

IntelliJ의 Preferences/Settings -> Build, Execution, Deployment -> Build Tools -> Gradle 로 이동하여

아래의 Gradle 설정이 나오는데, 이때 Gradle의 JVM이 Java 17이상인지 확인해야 합니다.

 

 

3.2 Project SDK

다음으로 File -> Project Structure.. 로 이동하여 프로젝트 SDK의 버전을 확인후 Java 17이상으로 설정해야 합니다.

 

Gradle Refresh 후 프로젝트를 실행하면 다음과 같이 정상적으로 실행되는것을 확인할수 있습니다.

블로그의 정보

생각보다 실천을

yjym33

활동하기