引导层初始化期间发生错误。 plexus.container.default:无效的模块名称:'default' 不是 Java 标识符
Posted
技术标签:
【中文标题】引导层初始化期间发生错误。 plexus.container.default:无效的模块名称:\'default\' 不是 Java 标识符【英文标题】:Error occurred during initialization of boot layer. plexus.container.default: Invalid module name: 'default' is not a Java identifier引导层初始化期间发生错误。 plexus.container.default:无效的模块名称:'default' 不是 Java 标识符 【发布时间】:2021-05-24 16:05:56 【问题描述】:我正在为我的应用程序使用 IntelliJ IDEA 2020.2.3 和 maven。
当我尝试调用 maven javafx:run 插件(就像每个 maven 插件一样)时,我收到了这样的警告:
[警告] 无法从中提取模块名称 plexus-container-default-1.7.1.jar:plexus.container.default:无效 模块名称:'default' 不是 Java 标识符
[警告] 一些依赖项在尝试使用时遇到问题 解析为模块,不会包含在类路径中;你可以 通过“includePathExceptionsInClasspath”更改此行为 配置参数。
应用程序正常运行。
但是,当我尝试在 IDE 中简单地运行 Main 类时,我收到了一个错误:
Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for C:\Users\hlebs\.m2\repository\org\codehaus\plexus\plexus-container-default\1.7.1\plexus-container-default-1.7.1.jar
Caused by: java.lang.IllegalArgumentException: plexus.container.default: Invalid module name: 'default' is not a Java identifier
这是我的 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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openjfx</groupId>
<artifactId>javafx-app</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>15.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>15.0.1</version>
</dependency>
<dependency>
<groupId>org.kordamp.ikonli</groupId>
<artifactId>ikonli-javafx</artifactId>
<version>12.2.0</version>
</dependency>
<dependency>
<groupId>org.kordamp.ikonli</groupId>
<artifactId>ikonli-remixicon-pack</artifactId>
<version>12.2.0</version>
</dependency>
<dependency>
<groupId>org.kordamp.ikonli</groupId>
<artifactId>ikonli-fontawesome-pack</artifactId>
<version>12.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.18</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-dependency-plugin -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.4</version>
<configuration>
<mainClass>org.openjfx.Launcher</mainClass>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>org.openjfx.Launcher</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>org.openjfx.Launcher</Main-Class>
<Build-Number>123</Build-Number>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
$project.build.directory/libs
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>libs/</classpathPrefix>
<mainClass>
org.openjfx.Launcher
</mainClass>
</manifest>
<manifestEntries>
<Automatic-Module-Name>assertj-core</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
我想运行 Main 类而不是运行 javafx:run 插件,因为当我测试某些功能时,它对我来说有点长且有害。另外我认为这样的错误不是正常情况。您有什么建议可以尝试?
删除对 maven-dependency-plugin 的依赖后,错误消失了,但现在我在尝试运行 Main 类时遇到其他错误:
Build output Printscreen
我的 module-info.java 看起来像:
module org.openjfx
requires javafx.controls;
requires javafx.fxml;
requires org.kordamp.ikonli.core;
requires org.kordamp.ikonli.javafx;
requires org.kordamp.ikonli.fontawesome;
requires org.kordamp.ikonli.remixicon;
requires java.sql;
requires java.desktop;
opens org.openjfx to javafx.fxml;
opens org.openjfx.ledicom.entities to javafx.base;
opens org.openjfx.ledicom.controllers.employee to javafx.fxml;
opens org.openjfx.ledicom.controllers.notifications to javafx.fxml;
opens org.openjfx.ledicom.controllers to javafx.fxml;
exports org.openjfx.ledicom.entities to java.sql;
exports org.openjfx;
【问题讨论】:
移除对maven-dependency-plugin
的依赖...
@khmarbaise 谢谢,我删除了对 maven-dependency-plugin 的依赖,错误消失了。但是现在当我尝试运行 Main 类时,我得到了其他错误,我在 qustion 编辑中描述了这些错误。你能看看吗?
依赖 javafx-controls 既不是模块(从我的角度来看)也不是可用的工件......
【参考方案1】:
在 pom.xml 我改变了
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>15.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>15.0.1</version>
</dependency>
到
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>16-ea+1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>16-ea+1</version>
</dependency>
换句话说,只是将javafx依赖版本编辑为16-ea+1。 现在一切正常。
【讨论】:
以上是关于引导层初始化期间发生错误。 plexus.container.default:无效的模块名称:'default' 不是 Java 标识符的主要内容,如果未能解决你的问题,请参考以下文章