Java 11 Eclipse找到自动模块,Maven没有 [英] Java 11 Eclipse finds automatic module, Maven does not

查看:219
本文介绍了Java 11 Eclipse找到自动模块,Maven没有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一个已有15年历史的Maven多模块项目升级到Java 11,以及Java 9中引入的模块系统.由于该项目是使用Maven构建的,因此所有依赖项都非常清楚.首先,我想使用自动模块名称来执行此操作,以免也引入升级的工件(如果不是绝对必需的话).

I'm attempting to upgrade a 15 year old Maven multimodule project to Java 11, and the module system that was introduced in Java 9. Since the project is built using Maven, all dependencies are pretty clear. First I want to do this using the automatic module names, in order not to also introduce upgraded artifacts (if not absolutely required).

Eclipse在此过程中非常有用,可以自动完成module-info.java中的自动模块名称.例如:

Eclipse is pretty helpful in this process, autocompleting the automatic module names in the module-info.java. For example:

requires dom4j;

但是,如果我使用Maven进行编译,则会收到有关无法在其中自动完成Eclipse的模块的错误消息.

But if I compile with Maven, I get errors about that it cannot find the modules Eclipse just autocompleted in there.

module-info.java:[29,18] module not found: dom4j

我正在使用Maven的编译器插件3.7.0(3.8.0根据 https://jira.apache.org/jira/browse/MCOMPILER-355 )我怀疑Maven在类路径而不是在模块路径上设置了jar,但是编译器的插件调试输出未记录该信息.

I am using Maven's compiler plugin 3.7.0 (3.8.0 gives a NullPointerException as per https://jira.apache.org/jira/browse/MCOMPILER-355) I suspect Maven is setting the jars up on the classpath instead of on the modulepath, but the compiler's plugin debug output does not log that.

如何使Maven正确处理那些模块?

How can I make Maven correctly handle those modules?

推荐答案

我遇到了同样的问题.添加

I was running into the same issue. Adding

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
        </plugin>
    </plugins>
</build>

我的pom为我解决了问题...

to my pom solved the problem for me...

这篇关于Java 11 Eclipse找到自动模块,Maven没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆