Spring boot 3.2.2 버전으로 스프링 부트 프로젝트를 생성해서 실행해보니 처음에 이런 에러가 발생했다.
원래는 Java 11을 사용하고 있었는데 Spring boot 3.x 버전부터는 Java 17 버전 이상을 지원하기 때문에, Java 21 버전을 새로 설치한 후 실행했는데도 똑같은 에러가 발생했다.
에러 코드를 보면 Java 17, Java11이 나와서 자바 버전의 문제인가 싶어서 자바 버전을 확인해보았다.
전체 에러 코드
A problem occurred configuring root project 'hello-srping'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.2.2.
Required by:
project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.2.2
> No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.2.2 was found. The consumer was configured to find a library for use during runtime, compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.5' but:
- Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.2 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 11
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '8.5')
- Variant 'javadocElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.2 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 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 '8.5')
- Variant 'mavenOptionalApiElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.2.2 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 11
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '8.5')
- Variant 'mavenOptionalRuntimeElements' capability org.springframework.boot:spring-boot-gradle-plugin-maven-optional:3.2.2 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 11
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '8.5')
- Variant 'runtimeElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.2 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 11
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '8.5')
- Variant 'sourcesElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.2 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 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 '8.5')
1. 로컬에 설치된 Java 버전 확인
cmd에서 현재 설치된 자바 버전을 확인한다.
2. build.gradle Java 버전 확인
해당 프로젝트의 build.gradle 에서 soureCompatibility 를 확인한다.
(start.spring.io/ 에서 프로젝트를 생성할 때, Java 버전을 잘못 선택해서 생성했는지 확인)
3. 인텔리제이 설정 확인
위의 1, 2 를 확인해도 문제가 없다면, 인텔리제이 설정을 확인한다.
Settings > Build,Execution, Deployment > Gradle > Gradle JVM
Gradle JVM이 21이 아닌 11로 선택되어 있었다.
JDK 21로 변경해주고 인텔리제이를 재실행하면 에러없이 잘 동작한다.
'Spring & SpringBoot' 카테고리의 다른 글
[Spring] 윈도우 cmd에서 Spring 프로젝트 빌드하고 실행하기 (0) | 2024.03.26 |
---|---|
[Spring] Spring Initializr 사용법 (0) | 2024.03.24 |