gpt4 book ai didi

java - Netbeans + Java 9 模块 + Log4j 2.11 = 找不到模块

转载 作者:行者123 更新时间:2023-12-05 07:33:35 25 4
gpt4 key购买 nike

我使用 Apache Netbeans 9 Beta 9(2018 年 2 月 22 日)。我有一个 Java 9 模块应用程序。我想将 Log4j 2 集成到我的应用程序中。这是我的 modile-info.java

module ru.itlect.remka.agent {

exports ru.itlect.remka.agent;

requires ru.itlect.remka.commons;
requires org.apache.logging.log4j.core;
requires org.apache.logging.log4j;

requires static spring.context;
requires java.logging;
requires java.xml;
requires java.sql;
requires java.desktop;
requires java.naming;
requires java.rmi;

requires static javafx.graphics;
requires static javafx.controls;
}

Netbeans 说找不到 org.apache.logging.log4j 模块。 虽然 org.apache.logging.log4j.core 是好的。当我构建项目时,它构建成功。所以问题出在 Netbeans 本身。 java --list-modules 表示 org.apache.logging.log4jlog4j-api-2.11.0.jar 中。如果我键入 requeres log,Netbeans 会建议 log4j.api,这是 log4j-api-2.11.0.jar 的自动模块名称。以为 Netbeans 说 log4j.api 也找不到。

我可以忍受 module-info.java 中不断出现的错误消息,但是 Netbeans 看不到 log4j-api-2.11.0.jar 中的任何类,所以我在任何使用的类中都有错误记录器。 如何让Netbeans看到模块?

这是我的 pom.xml 的一部分:

<dependencies>

<!-- Ремка -->
<dependency>
<groupId>ru.itlect.remka</groupId>
<artifactId>commons</artifactId>
<version>1.0.0</version>
</dependency>

<!--Spring-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.0.6.RELEASE</version>
</dependency>

<!-- Аннотации -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.5</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Logs -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.11.0</version>
</dependency>
</dependencies>

最佳答案

我在更新某些应用程序以使用 Log4j2 V2.11.1 作为模块时也遇到了问题。我创建了一个简单的测试用例并将其提交到 Netbeans 用户邮件列表。

今天早些时候,我们发现并修复了最新版本的 Netbeans 9 中的一个错误。 Pull request 941 , Geertjan 今天早上批准了,解释道。邮件列表 ( users@netbeans.incubator.apache.org ) 包含在将修复程序合并到新版本之前解决问题的建议。新版本正在进入 NetCAT (Community Acceptance Testing)过程。开发人员将感谢社区帮助更快地完成它,这可能是最好的前进方式。

如果您需要立即解决方案,讨论中建议的一种方法是编辑 jar 文件以将 module-info.class 文件移动到根结构中。

关于java - Netbeans + Java 9 模块 + Log4j 2.11 = 找不到模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50568139/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com