0

I'm collaborating with a friend on vscode, but my friend's spring works well, but mine doesn't work. There are two errors in total.

I tried various measures such as gradle plugin and java version, but it didn't work. For reference, the java version is 17.0.5 for both mac and vscode. Thank you for watching.

Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.6.1-bin.zip'.
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'rezume_project'.
A problem occurred configuring root project 'rezume_project'.
Could not resolve all files for configuration ':classpath'.
Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.4.
Required by:
    project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.0.4
No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.0.4 was found. The consumer was configured to find a runtime of a library compatible with Java 8, 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.0.4 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 8
      - 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.0.4 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 8)
          - 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.0.4 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 8
      - 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.0.4 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 8
      - 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.0.4 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 8
      - 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.0.4 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 8)
          - 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')
ddon
  • 1
  • 1
  • Hi & Welcome! sorry to correct, @"Leonard , but: spring-boot:3 works with java >= 8 ([proof](https://start.spring.io/)). Please show, @ddon, your (not-synced! ..so machine specific!)`settings.json`>`"java.configuration.runtimes"` ..also important: `"java.import.gradle.java.home"` [see also (not vs-code but gradle) related)](https://stackoverflow.com/q/68321708/592355), [see also most relevant doc](https://code.visualstudio.com/docs/java/java-build#_gradle) (you can [edit] your post;) – xerx593 Mar 22 '23 at 19:28
  • 1
    Sorry for the late reply. Reinstalling 'sdkman' solved the problem. thank you for the reply! – ddon Mar 25 '23 at 06:09

1 Answers1

0

The line

No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.0.4 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.6.1' but:

states that your project wants the library with Java 8 compatibility. However,

  • Variant 'runtimeElements' capability org.springframework.boot:spring-boot-gradle-plugin:3.0.4 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 8

says that all it could find, was a library that needs Java 17, which is correct as Spring Boot 3 requires Java 17.

So, your local build somehow runs on Java 8 or is configured with Java 8 as target. You should check that your shell runs with Java 17 or higher by running java -version. The same applies to your IDE configuration.

Leonard Brünings
  • 12,408
  • 1
  • 46
  • 66
  • Sorry for the late reply. Reinstalling 'sdkman' solved the problem. thank you for the reply! – ddon Mar 25 '23 at 06:09