Java 11 Eclipse finds automatic module, Maven does not

大兔子大兔子 提交于 2019-12-25 02:59:07

问题


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 is pretty helpful in this process, autocompleting the automatic module names in the module-info.java. For example:

requires dom4j;

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

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.

How can I make Maven correctly handle those modules?


回答1:


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>

to my pom solved the problem for me...



来源:https://stackoverflow.com/questions/55256736/java-11-eclipse-finds-automatic-module-maven-does-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!