このコンポーネントはJava 11と互換性のあるコンポーネントを宣言していますが、コンシューマーはJava 10と互換性のあるコンポーネントを必要としていたため、互換性がありません。質問する

このコンポーネントはJava 11と互換性のあるコンポーネントを宣言していますが、コンシューマーはJava 10と互換性のあるコンポーネントを必要としていたため、互換性がありません。質問する

build.gradle ファイルで、1 つの依存関係 (つまり、com.db:microservice-commons) のバージョンをアップグレードしました。Gradle の変更をロードした後、次のエラー メッセージが表示されます。

> Build file 'C:\Projects\Container\mschmidt\mount\booking-service\standalone\build.gradle' line: 50

   > A problem occurred evaluating project ':standalone'.
   > Could not resolve all files for configuration ':standalone:runtimeClasspath'.
   > Could not resolve com.db:microservice-commons:2.4.1.
     Required by:
         project :standalone
         project :standalone > project :service
      > No matching variant of com.db:microservice-commons:2.4.1 was found. The consumer was configured to find a runtime of a library compatible with Java 10, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally but:
          - Variant 'apiElements' capability com.db:microservice-commons:2.4.1 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 11 and the consumer needed a runtime of a component compatible with Java 10
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
          - Variant 'runtimeElements' capability com.db:microservice-commons:2.4.1 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 11 and the consumer needed a component compatible with Java 10
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
          - Variant 'samplessources' capability com.db:microservice-commons:2.4.1:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 10)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its usage (required a runtime)

ファイル 'C:\Projects\Container\mschmidt\mount\booking-service\standalone\build.gradle' の 50 行目以降は次のようになります。

manifest {
    def manifestClasspath = configurations.runtimeClasspath.collect { it.getName() }.join(' ')
    attributes 'Archiver-Version': 'Plexus Archiver'
    attributes 'Build-Jdk': org.gradle.internal.jvm.Jvm.current()
    attributes 'Main-Class': 'com.db.service.standalone.Standalone', 'Class-Path': manifestClasspath
    }
}

これをどう解釈したらよいのか全くわかりません。Project JDK と Gradle JVM は Java 11 に設定されています。この投稿は次のとおりです。コンシューマーは、jar としてパッケージ化された Java 11 と互換性のあるライブラリのランタイムとその依存関係を外部で宣言するように構成されていましたが、次の問題が発生しました。... 同じ問題に関係していますが、私には役に立ちませんでした。

ここで何が起こっているのか分かりますか?

ベストアンサー1

IntelliJ IDEA では、実行に使用する JDK Gradle を変更する必要がありました。元の値は JDK 11 でしたが、JDK 17 に変更しました。

スクリーンショット

おすすめ記事