パッケージ「com.exampleは」「javafx.base」と「javafx.base」の両方からパッケージ「javafx.beans」を読み込み、

ハンネス:

module-info.java、私のエラーを取得

パッケージ「com.exampleは」「javafx.base」と「javafx.base」の両方からパッケージ「javafx.beans」を読み込みます。

移行(Javaの11へのJava 8)はゆっくりと、しかし確実に私を失望するだけでなく、このエラーは、私にはどんな意味がありません。

FO私の依存関係の一部build.gradle

def springFrameworkVersion = '5.1.2.RELEASE'
def hibernateVersion = '5.3.7.Final'
def junitJupiterVersion = '5.3.1'

dependencies {
  compile 'org.transentials:cardhouse-commons:1.1.1'
  compile 'ch.qos.logback:logback-classic:1.2.3'
  compile "org.springframework:spring-context:$springFrameworkVersion"
  compile "org.springframework:spring-jdbc:$springFrameworkVersion"
  compile "org.springframework:spring-orm:$springFrameworkVersion"
  compile "org.hibernate:hibernate-core:$hibernateVersion"
  compile 'org.apache.commons:commons-dbcp2:2.5.0'
  compile 'org.apache.commons:commons-lang3:3.8.1'
  compile 'commons-io:commons-io:2.6'
  compile 'com.h2database:h2:1.4.197'
  compile 'javax.xml.bind:jaxb-api:2.3.1'
  compile 'com.google.guava:guava:27.0-jre'
  compile 'org.flywaydb:flyway-core:5.2.1'
  compile 'javax.validation:validation-api:2.0.1.Final'
  compile "org.openjfx:javafx-base:11:$platform"
  compile "org.openjfx:javafx-graphics:11:$platform"
  compile "org.openjfx:javafx-controls:11:$platform"
  compile "org.openjfx:javafx-fxml:11:$platform"
  testCompile 'junit:junit:4.12'

  testCompile 'org.mockito:mockito-core:2.+'
  testCompile 'de.saxsys:jfx-testrunner:1.2'
  testCompile 'org.apache.commons:commons-text:1.6'
  testCompile "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
  testCompile "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion"
  testCompile 'org.hamcrest:hamcrest-all:1.3'
}

そして、module-info.java

module open.terms.client.jfx {
  requires org.transentials.cardhouse.commons;
  requires com.google.common;
  requires org.apache.commons.lang3;
  requires org.hibernate.orm.core;
  requires java.persistence;
  requires slf4j.api;
  requires javafx.graphics;
  requires javafx.fxml;
  requires java.desktop;
}

誰かが、コンパイラは、このことで私に教えて欲しいものを私に説明できますか?

ホセ・ペリーダ:

あなたの中から必要なすべてのモジュールを削除した場合、依存関係の必要なリストでは、module-info、IDEはまだ同じエラーで文句を言うでしょう。

モジュールは、「javafx.base「と「javafx.base」」の両方から」javafx.beans「パッケージを読み込みます」

だから、問題はあなたのモジュール情報ではなく、自分の依存関係にありません。あなたはJavaFXののものを除いて、それらのすべてを、コメントアウトした場合、問題がなくなっています。

一部の依存性は、いくつかの不要なJavaFXの依存関係を持っている。この手段。

私は最初の依存関係をコメント化問題を特定するために管理してきました:

compile 'org.transentials:cardhouse-commons:1.1.1'

疑問は、なぜこれが起こって、どのように我々はそれを修正することができますされているので。

あなたはMavenの中央に行けばレポそれはGitHubのショーレポあなたが見つけることができます依存のbuild.gradleファイルとそのをmodule-info

予想通り、それは使用しています JavaFXのを:

compile "org.openjfx:javafx-base:11:$platform"

それもrequires javafx.baseその中にモジュールの情報

あなたの依存関係を持つこのアーティファクトを消費するとき、あなたは彼らのインポートしているjavafx.baseあなたのJavaFXの依存からあなたと一緒に、輸入をして競合があります。

この問題を解決するための最速の方法は自分のビルドでこれを変更しています。

compile 'org.transentials:cardhouse-commons:1.1.1'

これに:

compile ('org.transentials:cardhouse-commons:1.1.1') {
    exclude group: 'org.openjfx'
}

あなたはそのJavaFXの依存関係を除外しますとあなたを使用しますので。

より恒久的な修正は、アーティファクトを変更されるorg.transentials:cardhouse-commonsまでのモジュールの情報を:

`requires transitive javafx.base`

あなたはの使用について読むことができますtransitive ここで

問題は作者に報告してください。

注意

余談として、あなたは使用することができるjavafxのGradle プラグインにそれを簡素化し、ビルドのすべての関連のJavaFX部品の世話をします:

plugins {
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.0.5'
}

repositories {
    mavenCentral()
}

dependencies {
    compile ('org.transentials:cardhouse-commons:1.1.1') {
        exclude group: 'org.openjfx'
    }
    compile files('libs/cardhouse-commons-master-1.1.1.jar')
    ...
    compile 'javax.validation:validation-api:2.0.1.Final'
}

javafx {
    modules = [ 'javafx.controls', 'javafx.fxml' ]
}

mainClassName = 'open.terms.client.jfx.Main'

OpenJFXのドキュメントは、すでにこのプラグインを使用しています。

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=184449&siteId=1