πŸ’» Programming

[IntelliJ] μ‹ κ·œ 생성 ν”„λ‘œμ νŠΈμ˜ λΉŒλ“œ 였λ₯˜ (Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.2.1)

μΌ€μ΄μΉ˜ 2024. 1. 3. 10:35

졜근 2년정도 IntelliJμ—μ„œ Java 11 기반의 AWS Correto 11 을 μ‚¬μš©ν•΄μ™”μŠ΅λ‹ˆλ‹€

κ·Έλž˜μ„œ ν˜„μž¬ JAVA_HOME 은 AWS Correto 11 의 μœ„μΉ˜λ₯Ό 가리킀고 μžˆμ—ˆμŠ΅λ‹ˆλ‹€.

μ‹ κ·œ ν”„λ‘œμ νŠΈ ꡬ성할 일이 생겼고

AWS Correto 17 을 미리 λ‹€μš΄λ°›μ•„λ‘” μƒνƒœμ—μ„œ

IntelliJ μ—μ„œ SpringBoot Initializer λ₯Ό μ΄μš©ν•΄μ„œ

μ•„λž˜μ™€ 같은 μ„€μ •(Java 17 + gradle groovy)으둜 ν”„λ‘œμ νŠΈλ₯Ό μƒμ„±ν•˜κ³ 

λΉŒλ“œλ₯Ό ν•˜λ‹ˆ 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.

μŠ€ν”„λ§λΆ€νŠΈ μ‹ κ·œ ν”„λ‘œμ νŠΈ 생성 μ„€μ •ν™”λ©΄ (Java 17 μ„€μ •)

 

μ•„λž˜λŠ” λΉŒλ“œμ‹œ λ°œμƒν–ˆλ˜ 였λ₯˜ λ©”μ‹œμ§€

A problem occurred configuring root project 'my-new-springboot3-project'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.2.1.
     Required by:
         project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.2.1
      > No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.2.1 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.1 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.1 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.1 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.1 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.1 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.1 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')

* 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 1s

 

μ—λŸ¬ λ©”μ‹œμ§€μ˜ λ‚΄μš©μ„ μ½μ–΄λ³΄λ‹ˆ, μΌλ‹¨ Could not resolve xxx 의 경우 xxx λΌμ΄λΈŒλŸ¬λ¦¬κ°€ μ—†λ‹€λΌλŠ” λ©”μ‹œμ§€μΈλ°

μ‹ κ·œ μƒμ„±ν•œ ν”„λ‘œμ νŠΈμ—μ„œ ν•„μˆ˜λΌμ΄λΈŒλŸ¬λ¦¬λ₯Ό dependency에 μ•ˆλ„£μ„ μ΄μœ κ°€ μ—†λ‹€λŠ” 생각이 μš°μ„  λ“€μ—ˆμŠ΅λ‹ˆλ‹€.

그런거라면 springboot initializer 의 λ²„κ·ΈμΌν…Œλ‹ˆκΉŒμš”.

κ·Έλž˜μ„œ 더 μ½μ–΄λ΄€μŠ΅λ‹ˆλ‹€.

그리고 "requierd compatibility with Java 11" 문ꡬ가 λˆˆμ— λ„μ—ˆμŠ΅λ‹ˆλ‹€.

λ‚œ μžλ°”17을 μ“°λ €κ³  17λ²„μ „μœΌλ‘œ JDK와 Java 섀정을 λ„£μ—ˆλŠ”λ° μ™œ Java 11 κ΄€λ ¨λ©”μ‹œμ§€κ°€ λœ¨λŠ”κ±΄μ§€ μ΄μƒν–ˆμŠ΅λ‹ˆλ‹€. πŸ€”

μ—λŸ¬λ©”μ‹œμ§€ λ‚΄μš©μœΌλ‘œ ꡬ글링을 μ’€ ν•΄λ³΄λ‹ˆ μ•„λž˜ 뢀뢄듀을 ν™•μΈν•΄λ³΄λΌλŠ” λ‚΄μš©λ“€μ΄ μžˆμ—ˆμŠ΅λ‹ˆλ‹€.

  • ν˜„μž¬ μ‹œμŠ€ν…œμ—μ„œ μ‚¬μš©ν•˜λŠ” Java 버전 확인 (java -version)
  • build.gradle 파일의  sourceCompatibility 확인
  • IntelliJ 의 project SDK μ„€μ • 확인
  • gradle JVM μ„€μ • 확인

일단 λΉŒλ“œμ‹œμ— λ°œμƒν–ˆκ³ , λΉŒλ“œνˆ΄μ€ gradle μ΄λΌλŠ” κ±Έ 이미 ν”„λ‘œμ νŠΈ μƒμ„±μ‹œ 섀정을 ν•΄μ£Όμ—ˆκ³ , IntelliJ에 gradle 이 μ‚¬μš©ν•  μžλ°”λ²„μ „μ„ μ„€μ •ν•˜λŠ” λ‚΄μš©μ΄ μžˆλ‹€λŠ” 것을 μ•Œκ³ μžˆμ—ˆκΈ°μ— gradle JVM 섀정을 λ¨Όμ € ν™•μΈν•΄λ΄€μŠ΅λ‹ˆλ‹€.

gradle JVM 섀정이 κΈ°μ‘΄ μ„€μ • κ·ΈλŒ€λ‘œ Java 11을 μ‚¬μš©ν•˜λ„λ‘ λ˜μ–΄μžˆμ—ˆμŠ΅λ‹ˆλ‹€. 😭

ν”„λ‘œμ νŠΈ μƒμ„±μ‹œ correto 17, Java 17 버전을 μ„€μ •ν•΄μ£Όμ—ˆκΈ°μ— sourceCompatibility 와 project SDK λŠ” 17버전을 μ‚¬μš©ν•˜λ„λ‘ λ˜μ–΄μžˆμ—ˆκ³ , JAVA_HOME에 μ„€μ •λ˜μ–΄μžˆλŠ” ν˜„μž¬ μ‹œμŠ€ν…œμ—μ„œ 기본으둜 μ‚¬μš©μ€‘μΈ Java λ²„μ „κ³ΌλŠ” 관계가 μ—†μ—ˆμŠ΅λ‹ˆλ‹€.

 

gradle JVM μ„€μ • 확인 방법

Preferences/Settings (⌘ + , ) > Build, Execution, Deployment > Build Tools > Gradle

Gradle JVM μ„€μ • ν™”λ©΄

project SDK μ„€μ • 확인 방법

File > Project Structure.. (⌘ + ; )

Project SDK μ„€μ • ν™”λ©΄

build.gradle 파일의 sourceCompatibility 확인 방법

build.gradle νŒŒμΌμ—μ„œ sourceCompatibility μ„€μ • 방법