eclipse和maven:启动层初始化期间出错

b0zn9rqh  于 2021-09-13  发布在  Java
关注(0)|答案(1)|浏览(469)

布翁吉奥诺,
我有一个带有一些额外依赖项的java项目,我想让maven来处理它。
因此,我在pom.xml中添加了所有依赖项,并用maven更新了项目。在maven dependencies中,我拥有运行程序所需的所有软件包,但是我无法再次运行我的项目,因为我遇到以下错误:

Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.base not found

我是否仍然必须在vm参数(run config)中添加模块,还是因为它们是在maven中添加的,所以不需要它们?
如果在没有任何vm参数的情况下运行它,我会得到以下结果:

Error: JavaFX runtime components are missing, and are required to run this application

以下是maven依赖项的屏幕截图:

编辑:我可以使构建工作正常,但如果我想运行创建的.jar文件,它会给我以下错误:

Error: JavaFX runtime components are missing, and are required to run this application

my pom.xml:

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>kantinen_managementsystem</groupId>
  <artifactId>kantinen_managementsystem</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>Test KMS Maven</name>
  <description>Test Maven Build</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <maven.compiler.source>16</maven.compiler.source>
    <maven.compiler.target>16</maven.compiler.target>
        <java.version>16</java.version>
    </properties>  

  <build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
      <resource>
        <directory>images</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>

  <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.2.0</version>
        <configuration>
          <archive>
            <manifest>
                <addClasspath>true</addClasspath>
              <mainClass>KMS.Main</mainClass>
            </manifest>
          </archive>
        </configuration>
      </plugin>    

      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
            <archive>
            <manifest>
                <addClasspath>true</addClasspath>
            <mainClass>KMS.Main</mainClass>
            </manifest>
            </archive>
          <release>16</release>
        </configuration>
      </plugin>

    <plugin>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-maven-plugin</artifactId>
        <version>0.0.6</version>
        <configuration>
            <mainClass>KMS.Main</mainClass>
        </configuration>
    </plugin>    

      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.3.0</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
            <archive>
            <manifest>
                <addClasspath>true</addClasspath>
            <mainClass>KMS.Main</mainClass>
            </manifest>
            </archive>        
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
      </plugin> 

    </plugins>
  </build>

  <dependencies>
    <dependency>                                                    <!-- PostgreSQL -->
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>42.2.20</version>
    </dependency>

    <dependency>                                                    <!-- AnimateFX -->
        <groupId>io.github.typhon0</groupId>
        <artifactId>AnimateFX</artifactId>
        <version>1.2.1</version>
    </dependency>

    <dependency>
        <groupId>de.jensd</groupId>
        <artifactId>fontawesomefx</artifactId>
        <version>8.2</version>
    </dependency>

    <dependency>                                                    <!-- JavaFX - Controls -->
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>16</version>
    </dependency>

    <dependency>                                                    <!-- JavaFX - Graphics -->
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-graphics</artifactId>
        <version>16</version>
    </dependency>

    <dependency>                                                    <!-- JavaFX - Base -->
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-base</artifactId>
        <version>16</version>
    </dependency>

    <dependency>                                                    <!-- JavaFX - FXML -->
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>16</version>
    </dependency>

    <dependency>                                                    <!-- JavaFX - Web -->
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-web</artifactId>
        <version>16</version>
    </dependency>

<dependency>                                                    <!-- JavaFX - Swing -->
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-swing</artifactId>
    <version>16</version>
</dependency>

<dependency>                                                    <!-- JavaFX - Media -->
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-media</artifactId>
    <version>16</version>
</dependency>
xa9qqrwz

xa9qqrwz1#

可以将javafx文件移动到其他位置吗?例如c:/有时此类错误可能与文件位置有关。复制文件后重新定义。您可以打开另一个项目并尝试。我的回答可能不好,但我想给出一个想法。

相关问题