• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

./gradlew clean build 에러 발생

23.05.27 16:27 작성 조회수 820

0

[질문 템플릿]
1. 강의 내용과 관련된 질문인가요? 예
2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? 예
3. 질문 잘하기 메뉴얼을 읽어보셨나요? 예

[질문 내용]
./gradlew clean build를 했을 때 아래와 같은 에러가 발생합니다.

구글 드라이브 링크: https://drive.google.com/file/d/1noPIwH5K_JrQ_st4-VSuOOqVLuLBopJw/view?usp=sharing

$ ./gradlew clean build

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'jpashop'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.1.0.
     Required by:
         project : > org.springframework.boot:org.springframework.boot.gradle.plugin: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')

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

* Get more help at https://help.gradle.org

BUILD FAILED in 4s

답변 3

·

답변을 작성해보세요.

0

y2gcoder님의 프로필

y2gcoder

2023.05.31

안녕하세요, jihoon Yoo 님. 공식 서포터즈 y2gcoder 입니다.

AI 답변과 같이 스프링 부트 버전과 설치하신 JDK 버전이 맞지 않아서 발생한 문제로 보입니다. 스프링 부트 3버전을 사용하시려면 JDK도 17버전으로 올려주셔야 합니다 :)

감사합니다.

0

인프런 AI 인턴님의 프로필

인프런 AI 인턴

2023.05.29

안녕하세요, 인프런 AI 인턴이에요.

에러 대해서 먼저 간단하게 설명 드릴게요.
해당 에러는 프로젝트에서 사용하고 있는 Spring Boot의 버전과 Gradle 버전이 호환되지 않아 발생하는 에러입니다.

해결 방법으로는 두 가지가 있습니다.
1. 프로젝트에서 사용하는 Spring Boot 버전을 Gradle 버전에 맞춰 변경해주는 것입니다.
2. 현재 사용중인 Gradle 버전을 Spring Boot 버전에 맞춰 업그레이드 하는 것입니다.

2번 방법을 사용할 경우 아래와 같이 Gradle 설정 파일(build.gradle)을 수정해주셔야 합니다.

build.gradle 파일에서 다음과 같은 내용을 찾아서 수정해주세요.

classpath("org.springframework.boot:spring-boot-gradle-plugin:3.1.0")

위 내용을 아래와 같이 수정해주세요.

classpath("org.springframework.boot:spring-boot-gradle-plugin:2.6.3")

이후, 다시 ./gradlew clean build 명령어를 실행해보시면 정상적으로 빌드가 진행될 것입니다.

어려운 문제였을텐데, 제가 도움이 될 수 있어서 좋았습니다. 이용해주셔서 감사합니다.

-1

jihoon Yoo님의 프로필

jihoon Yoo

질문자

2023.05.31

imageimage

위 두 부분 모두 17로 돼있는 상태였는데 안 되는 이유가 있을까요..?

y2gcoder님의 프로필

y2gcoder

2023.05.31

보여주신 부분은 IDE에서의 JDK 설정입니다 :)
질문에서 보여주신 것처럼 터미널에서 gradle 명령어를 사용하고자 하신다면 환경변수 설정이 필요합니다.

chaesc1223님의 프로필

chaesc1223

2023.12.24

환경변수 설정 또한 완료하였는데 동일한 에러가 계속 발생하는데 뭐가 문제인지 모르겠습니다.

y2gcoder님의 프로필

y2gcoder

2023.12.25

위의 답변과 밑의 답변에서 사용하신 터미널이 달라보입니다!

위의 답변에서 사용한 터미널에서 java --version을 입력했을 때도 동일하게 17버전이 나올까요?