简体   繁体   English

Netbeans + Java 9模块+ Log4j 2.11 =未找到模块

[英]Netbeans + Java 9 Modules + Log4j 2.11 = Module not found

I use Apache Netbeans 9 Beta 9 (22 February 2018). 我使用Apache Netbeans 9 Beta 9(2018年2月22日)。 I have a Java 9 Module application. 我有一个Java 9 Module应用程序。 And I want to integrate Log4j 2 into my application. 我想将Log4j 2集成到我的应用程序中。 Here is my modile-info.java . 这是我的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 says that org.apache.logging.log4j module is not found. Netbeans说找不到org.apache.logging.log4j模块。 Though org.apache.logging.log4j.core is OK. 虽然org.apache.logging.log4j.core可以。 When I build the project, it is built successfully. 当我构建项目时,它会成功构建。 So the problem is in Netbeans itself. 因此问题出在Netbeans本身。 java --list-modules says that the org.apache.logging.log4j is in log4j-api-2.11.0.jar . java --list-modules表示org.apache.logging.log4jlog4j-api-2.11.0.jar If I type requeres log Netbeans suggests log4j.api which the automatic module name for log4j-api-2.11.0.jar . 如果我键入requeres log Netbeans建议使用log4j.api ,其自动模块名称为log4j-api-2.11.0.jar Thought Netbeans says that log4j.api is ot found either. Netbeans认为该log4j.api也可以找到。

I can live with the constant error message in module-info.java, but Netbeans cannot see any class in log4j-api-2.11.0.jar so I have errors in any class which uses loggers. 我可以在module-info.java中处理持续的错误消息,但是Netbeans在log4j-api-2.11.0.jar不到任何类,因此在使用记录器的任何类中都存在错误。 How to make Netbeans see the module? 如何使Netbeans看到模块?

This is a part from my pom.xml: 这是我的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>

I too was having trouble updating some applications to use Log4j2 V2.11.1 as a module. 我也无法更新某些应用程序以使用Log4j2 V2.11.1作为模块。 I created a simple test case and raised it on the Netbeans users mailing list. 我创建了一个简单的测试用例,并将其放在Netbeans用户邮件列表中。

As of earlier today, a bug in the latest release of Netbeans 9 was found and fixed. 截至今天早些时候,发现并修复了最新版本的Netbeans 9中的错误。 Pull request 941 , which Geertjan approved this morning, explains. Geertjan今天上午批准的请求请求941进行了解释。 The mailing list ( users@netbeans.incubator.apache.org ) contains suggestions for working around the problem ahead of the fix being merged into a new release. 邮件列表( users@netbeans.incubator.apache.org )包含一些建议,可以在修复程序合并到新发行版之前解决该问题。 A new release is entering the NetCAT (Community Acceptance Testing) process. 一个新版本正在进入NetCAT(社区接受测试)过程。 The developers would appreciate community help to finish it faster, which is probably the best way forward. 开发人员希望社区提供帮助以更快地完成它,这可能是最好的方法。

If you need an immediate solution, one suggested approach from the discussion is to edit the jar file to move the module-info.class file into the root structure. 如果您需要立即解决方案,那么讨论中建议的一种方法是编辑jar文件,以将module-info.class文件移到根结构中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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