7

Win 10 マシンで InteliJ と Maven を使用してアプリケーションを実行しようとしています。私が走れば

mvn clean javafx:run

GUI は起動しますが、org.controlsfx.control.textfield.TextFields の Textfield を使用すると問題が発生します

Exception in thread "JavaFX Application Thread" java.lang.IllegalAccessError: class org.controlsfx.control.textfield.AutoCompletionBinding (in unnamed module @0x19b440d0) cannot access class com.sun.javafx.event.EventHandlerManager (in module javafx.base) because module javafx.base does not export com.sun.javafx.event to unnamed module @0x19b440d0

これは既知の問題であり、次のコマンドを JVM に渡す必要があることがわかりました。

--add-exports=javafx.base/com.sun.javafx.event=org.controlsfx.controls

しかし、どうすればmavenでこれを行うことができますか? 私は2つの方法を試しました。

方法 1: .mvn/jvm.config ファイルを使用してこのコマンドを追加しますが、そこに sensless を入力しても何も変わりません。

方法 2: --add-export コマンドを使用してシステム変数MAVEN_OPTSを 追加します。次に、maven はこの変更に反応しますが、次のように言います。

WARNING: Unknown module: org.controlsfx.controls specified to --add-exports

どうすればこれを修正できますか?

編集:方法 3: https://github.com/openjfx/javafx-maven-pluginに よると、この --add-export を javafx-maven-plugin に追加できるはずですが、InteliJ はこれをこの要素が無効であるとマークしますこの場所では使用できません

<plugin>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-maven-plugin</artifactId>
    <version>0.0.4</version>
    <configuration>
        <compilerArgs>
            <arg>--add-exports</arg>
            <arg>javafx.graphics/com.sun.glass.ui=org.openjfx.hellofx</arg>
        </compilerArgs>
        <mainClass>org.openjfx.hellofx/org.openjfx.App</mainClass>
    </configuration>
</plugin>

https://github.com/openjfx/javafx-maven-plugin/issues/53は既知のようですが、問題とは見なされていません

4

1 に答える 1

5

この問題を見つけた人のために、javaFX プラグインは方法 3 で説明されているコンパイラ オプションをサポートしなくなりました。

次のように、引数をコンパイラ プラグインに追加する必要があります。

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.8.1</version>
      <configuration>
        <compilerArgs>
          <arg>--add-exports</arg>
          <arg>java.management/sun.management=ALL-UNNAMED</arg>
        </compilerArgs>
      </configuration>
    </plugin>
  </plugins>
</build>
于 2021-06-20T17:13:13.930 に答える