0

最近我构建了一个简单的 JavaFX 应用程序,并使用了 OracleJDK 10 和它的 JavaFX,之后,我决定更新到 Java 11 (OpenJDK 11.0.2) + OpenJFX 11 - 我得到以下构建错误: 在此处输入图像描述

这是我的pom.xml

<?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">

<modelVersion>4.0.0</modelVersion>

<groupId>store.management.desktop</groupId>
<artifactId>desktop</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>desktop</name>

<properties>
    <java.version>11</java.version>
    <maven.compiler.source>${java.version}</maven.compiler.source>
    <maven.compiler.target>${java.version}</maven.compiler.target>
    <unirest.version>1.4.9</unirest.version>
    <jackson.version>2.9.8</jackson.version>
    <hibernate.version>5.2.12.Final</hibernate.version>
    <jbos.transaction.api.version>2.0.0.Alpha1</jbos.transaction.api.version>
    <flyway.version>5.2.4</flyway.version>
    <jfoenix>9.0.2</jfoenix>
    <h2.version>1.4.197</h2.version>
</properties>

<build>
    <finalName>desktop</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <release>${java.version}</release>
                <source>${java.version}</source>
                <target>${java.version}</target>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>${jackson.version}</version>
    </dependency>
    <dependency>
        <groupId>com.mashape.unirest</groupId>
        <artifactId>unirest-java</artifactId>
        <version>${unirest.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate.version}</version>
    </dependency>
    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-maven-plugin</artifactId>
        <version>${flyway.version}</version>
    </dependency>
    <dependency>
        <groupId>com.jfoenix</groupId>
        <artifactId>jfoenix</artifactId>
        <version>${jfoenix}</version>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>${h2.version}</version>
    </dependency>

    <!-- FontawesomeFX -->
    <dependency>
        <groupId>de.jensd</groupId>
        <artifactId>fontawesomefx-commons</artifactId>
        <version>9.1.2</version>
    </dependency>
    <dependency>
        <groupId>de.jensd</groupId>
        <artifactId>fontawesomefx-fontawesome</artifactId>
        <version>4.7.0-9.1.2</version>
    </dependency>
    <dependency>
        <groupId>de.jensd</groupId>
        <artifactId>fontawesomefx-materialdesignfont</artifactId>
        <version>2.0.26-9.1.2</version>
    </dependency>

    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>javax.activation-api</artifactId>
        <version>1.2.0</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-core</artifactId>
        <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.3.0</version>
    </dependency>

    <!-- JavaFX - OpenJFX -->
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>11.0.2</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>11.0.2</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-base</artifactId>
        <version>11.0.2</version>
    </dependency>

</dependencies>

这是我的module-info.java

module store.management.desktop {
    requires unirest.java;
    requires jackson.annotations;
    requires com.fasterxml.jackson.databind;

    requires com.jfoenix;

    requires javafx.graphics;
    requires javafx.fxml;
    requires javafx.controls;
    requires javafx.base;
    requires java.desktop;

    requires hibernate.jpa;
    requires hibernate.core;
    requires org.flywaydb.core;
    requires com.fasterxml.jackson.core;

    exports store.management.desktop;
}

更新 在此处输入图像描述

我尝试了几种不同的方法来解决这个问题(花了很多时间),但没有一种方法可以帮助我。也许有人知道如何解决这个问题?谢谢

4

1 回答 1

0

作为一种解决方法,您可以尝试在 pom 中排除源:

<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-controls</artifactId>
    <version>11.0.2</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.maven</groupId>
                <artifactId>maven-core</artifactId>
            </exclusion>
        </exclusions>
 </dependency>

对于所有事情,这都会给你一个错误......因此,你可以使用通配符(*)来表示组和 artifactId。虽然这可能是一种解决方法,但我认为真正的问题在于 Maven 设置。

于 2019-02-04T13:07:11.160 回答