Spring Boot 3.0 이상

CJY·2023년 6월 21일
0

설정 문제

목록 보기
1/2

이전까지 스프링 부트 3.0 이하의 버전으로 프로젝트를 만들었다.

그런데 2023년 6월 21일 기준으로 3.1.0이 가장 최신 버전이고 2점대 버전이 곧 없어질 것 같아 오늘 토이 프로젝트는 3.1.0 버전을 택했다.

No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.1.0 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.1' but:
          - Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.1.0 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.1')
          - Variant 'javadocElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.1.0 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.1')
          - Variant 'mavenOptionalApiElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.1.0 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.1')
          - Variant 'mavenOptionalRuntimeElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.1.0 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.1')
          - Variant 'runtimeElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.1.0 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.1')
          - Variant 'sourcesElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.1.0 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.1')

처음 빌드를 진행했을 때 위와 같은 오류가 나와 머리가 어지러웠다.

자세히 보면 Java 11Java 17이 자주 등장하는 것을 볼 수 있다.

현재 내가 사용 중이었던 자바 버전은 11이었고, 스프링 부트 3.0부터는 Java 17 버전 이상을 사용해야 한다.

해결 방법

여러 해결 방법이 있겠지만 내가 사용한 방법은 아래와 같다.

결론부터 말하자면 우리의 똑똑한 인텔리제이를 활용했다.

mac 기준 preferences
window 기준 settings에 들어가줍니다.
settings / Build, Execution, Deployment / Build Tools / Gradle에 들어가서

Gradle JVM 항목을 찾아줍니다.


사진을 보면 인텔리제이에서 JDK를 다운로드 받을 수 있습니다 !

저는 처음에 20을 다운받았지만 잘 호환이 안되서 17을 새로 다운 받았습니다.

저는 Temurin으로 다운로드 받았습니다.

그리고 다운로드 한 17버전을 Gradle JVM에 넣어줍니다.

추가로 프로젝트 구조도 확인해주세요!


SDK가 17이상인지 확인하고 안돼있다면 바꿔주면 됩니다!


설정을 바꾸고 그래이들을 새로 빌드해주면 잘 동작한답니다~

profile
열심히 성장 중인 백엔드

0개의 댓글