[Error] Gradle Build Incompatible Java17, Java17 에러 해결

YUNU·2023년 12월 3일
1

TROUBLESHOOTING

목록 보기
3/4
post-thumbnail

🟦 error:

Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 11


🟦 문제 발생

Java 11, Springboot 2.7.x 버전을 사용 중이었으나
진행중이던 프로젝트를 Java 17, Springboot 3.2.x 버전으로 업그레이드 함

IntelliJ에서 모든 설정을 Java 11 -> Java 17로 변경하였고
문제 없이 프로젝트를 진행중이었음

삭제한 파일과 Bean 충돌하는 에러가 발생하여
./gradlew clean 명령어를 입력
➡️ 명령어가 수행되지 않고 아래와 같은 에러가 발생함

FAILURE: Build failed with an exception.
figuration1
* What went wrong:
A problem occurred configuring root project 'healthyFriends'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.2.0.
     Required by:
         project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.2.0
      > No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.2.0                   m
 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.4' but:
          - Variant 'apiElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.0 declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component for use during compile-time      e
, compatible with Java 17 and the consumer needed a component for use during runtime, compati             ible with Java 11
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.4')    
          - Variant 'javadocElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.0 declares a component for use during runtime, and its dependencies declared externally:        
              - Incompatible because this component declares documentation and the consumer n             needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Ja    ava 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.4')    
          - Variant 'mavenOptionalApiElements' capability org.springframework.boot:spring-boot-gradle-plugi
n-maven-optional:3.2.0 declares a library, packaged as a jar, and its dependencies declared external      lly:
              - Incompatible because this component declares a component for use during compile-time      e
, compatible with Java 17 and the consumer needed a component for use during runtime, compati             ible with Java 11
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.4')    
          - Variant 'mavenOptionalRuntimeElements' capability org.springframework.boot:spring-boot-gradle-p
lugin-maven-optional:3.2.0 declares a library for use during runtime, packaged as a jar, and its dep      pendencies declared externally:
              - Incompatible because this component declares a component, compatible with Java 17
[0[11;107H0;39m 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.4')    
          - Variant 'runtimeElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.0 d
eclares a library for use during runtime, packaged as a jar, and its dependencies declared externall      ly:
              - Incompatible because this component declares a component, compatible with Java 17
[0[11;107H0;39m 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.4')    
          - Variant 'sourcesElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.2.0 declares a component for use during runtime, and its dependencies declared externally:        
              - Incompatible because this component declares documentation and the consumer n             needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Ja    ava 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.4') 

🟦 문제 해결

Gradle은 Java 컴파일을 위해 System Path의 JAVA_HOME을 사용

나의 기존 JAVA_HOME은 Java 11로 설정되어 있음

JAVA_HOME과의 충돌을 막기 위해 시스템 환경 변수에서 JAVA_HOME 수정하여 문제 해결 시도

시스템 환경 변수에서 JAVA_HOME의 값을 JAVA 17이 설치된 패키지의 경로로 변경

IntelliJ를 종료 후 재시작 -> ./gradlew clean 수행

profile
DDeo99

1개의 댓글

comment-user-thumbnail
2024년 1월 18일

같은 문제로 고민하고 있었어요. 좋은 글 감사합니다.

답글 달기