小编sre*_*epo的帖子

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

我正在使用这个Github项目来接触Java 9中的新模块化功能.我想为项目添加依赖项并能够构建本机映像.但是,当我尝试向pom.xml添加新的依赖项,并将requires语句添加到module-info.java时,我从maven-jlink-plugin中收到以下错误:

Error: module-info.class not found for joda.time module
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用它作为概念证明,我可以使用新的链接阶段部署图像,但自然我需要能够具有外部依赖性,我需要使用maven(工作约束).

对mod-jar/pom.xml的更改

...
 <dependencies>
    <dependency>
      <groupId>joda-time</groupId>
      <artifactId>joda-time</artifactId>
      <version>2.9.9</version>
    </dependency>
  </dependencies>
...
Run Code Online (Sandbox Code Playgroud)

MOD-罐/ module-info.java

module com.soebes.nine.jar {
  requires java.base;
  requires joda.time;
  exports com.soebes.example.nine.jar;
}
Run Code Online (Sandbox Code Playgroud)

日志:

[INFO] --- maven-jlink-plugin:3.0.0-alpha-1:jlink (default-jlink) @ mod-jlink ---
[INFO] Toolchain in maven-jlink-plugin: jlink [ /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/bin/jlink ]
[INFO] The following dependencies will be linked into the runtime image:
[INFO]  -> module: com.soebes.nine.one ( /Users/sebastianrestrepo/Projects/jdk9-jlink-jmod-example/maven-example/mod-1/target/jmods/com.soebes.nine.one.jmod )
[INFO]  -> module: com.soebes.nine.two ( /Users/sebastianrestrepo/Projects/jdk9-jlink-jmod-example/maven-example/mod-2/target/jmods/com.soebes.nine.two.jmod )
[INFO]  -> module: com.soebes.nine.jar ( …
Run Code Online (Sandbox Code Playgroud)

java jodatime jlink maven java-9

5
推荐指数
2
解决办法
2190
查看次数

标签 统计

java ×1

java-9 ×1

jlink ×1

jodatime ×1

maven ×1