且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

有没有办法在使用maven-jlink-plugin时添加maven依赖项?

更新时间:2022-06-12 22:21:22

这有与我相信的插件没什么关系。模块 joda.time 在您的情况下似乎是自动模块

This has not much to do with the plugin I believe. Module joda.time in your case seems to be an automatic module.

jlink 工具不支持链接自动模块因为它们可以依赖类路径的任意内容,这违背了自我的想法包含Java运行时。

The jlink tool does not support linking of automatic modules because they can rely on the arbitrary content of the classpath, which goes against the idea of a self-contained Java runtime.

所以有两种方法可以解决这个问题: -

So there are two ways to fix this probably :-


  • (你不拥有jar)暂时继续创建 module-info.java [你可以使用 jdeps 工具并更新jar [使用 jar tool],带有相应的编译类,如Java 9中的项目。

  • (you don't own the jar) Temporarily go ahead create a module-info.java[you could use jdeps tool for it] and update the jar[using jar tool] with the corresponding compiled class as in projects under Java 9.

(你拥有依赖项)永久地将jar迁移到Java 9本身,在编译和打包后,它将由 module-info.class 组成。

(you own the dependency) Permanently migrate the jar to Java 9 itself, where it would consist of the module-info.class by itself after being compiled and packaged.