如何在自动库中使用jlink

问题描述 投票:0回答:1

我遇到了无法使用jlink进行编译的问题,现在我有点知道哪里出了问题:jlink无法编译自动化模块,因为它们的名称不稳定。是否有解决方法或解决方法?这是我的代码的相关部分:

module-info.java

module org.example {
    requires MathParser.org.mXparser;

    exports org.example;
}

pom.xml

...
<dependency>
    <groupId>org.mariuszgromada.math</groupId>
    <artifactId>MathParser.org-mXparser</artifactId>
    <version>4.4.2</version>
</dependency>
...

Main.java

...
import org.mariuszgromada.math.mxparser.*;
...

[使用jlink编译时,会显示此错误消息:

Required filename-based automodules detected. Please don't publish this project to a public artifact repository!

此问题不可重复,因为尚未回答。建议的问题未得到修复或解决方法。它仍然可以回答技术问题:What does "Required filename-based automodules detected." warning mean?

java java-module jlink
1个回答
0
投票

不,您的情况没有解决方法。 jlink不支持自动模块(即使稳定名称也无济于事)。您需要先将自动模块转换为显式模块。好消息是您不必重新编译库。您可以使用jdeps --generate-module-info生成模块声明,然后将其注入JAR。在this question中对此进行了描述。

© www.soinside.com 2019 - 2024. All rights reserved.