简体   繁体   中英

Assistance to Java Module: Module 'name' reads package 'javafx.beans'

Currently, I am trying to link a maven project with Java 9's module system however I keep getting the same error in every module.. (using Java 11)

Module 'common' reads package 'javafx.beans' from both 'javafx.base' and 'javafx.base'

I have been struggling with it for hours now. So far, I can conclude that every time I require javafx module it happens and it has probably something to do with duplication. In Project Structure (Intellij IDEA) two of each exists, version 11.0.2 (I have installed) and version 11.0.1 (from fontawesomefx). If I remove all the 11.0.1 versions, the implementation won't work.

module-info.java

module common {
    exports common.services;
    exports common.sidebar;
    requires de.jensd.fx.fontawesomefx.commons;
    requires javafx.graphics; // comment both javafx out, no error occurs except in the implementation.
    requires javafx.controls;
}

pom.xml of common:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <parent>
    <artifactId>parent</artifactId> <!-- replaced original id -->
    <groupId>me.name</groupId> <!-- replaced original name -->
    <version>0.0.6</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>

  <artifactId>common</artifactId>

  <dependencies>
    <dependency>
      <groupId>de.jensd</groupId>
      <artifactId>fontawesomefx-commons</artifactId>
    </dependency>

    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-controls</artifactId>
    </dependency>
  </dependencies>
</project>

I hope this is enough information otherwise I can provide more. Thanks!

So I found a solution today. It is all about duplication, so I searched to see if it was possible to exclude packages from a dependency and it is!

<dependency>
    <groupId>de.jensd</groupId>
    <artifactId>fontawesomefx-commons</artifactId>
    <version>11.0</version>
    <exclusions>
        <exclusion>
            <groupId>org.openjfx</groupId>
            <artifactId>*</artifactId>
        </exclusion>
    </exclusions>
</dependency>

I added the <exclusions></exclusions> tags to all another libraries with javafx as requirement and it worked!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM