gpt4 book ai didi

java - ModiTect 和 Jlink 找不到模块依赖项

转载 作者:行者123 更新时间:2023-12-03 10:04:54 26 4
gpt4 key购买 nike

我已经配置了ModiTect生成 module-info.java s 对于我所有的依赖项(没有它们),这似乎是有效的;但是当涉及到确实拥有它们的依赖项时,它并没有找到它们。对于我自己的 jar ,我正在写 module-info.java用手。

当我运行 mvn package在我的应用程序中它失败了:

Error: Module tech.flexpoint.dashmancommon not found, required by tech.flexpoint.dashmanserver

命令行如下所示:
C:\Program Files\Java\jdk-10.0.1\bin\jlink --add-modules tech.flexpoint.dashmanserver --module-path C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\modules;C:\Program Files\Java\jdk-10.0.1\jmods;C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\classes --output C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\jlink-image --launcher dashmanserver=tech.flexpoint.dashmanserver

我知道 tech.flexpoint.dashmancommon是一个模块并且有一个 module-info.java因为我自己 build 的。如何让 ModiTect/jlink 在其原始 jar 中找到所有依赖模块?

我正在 build 的 ModiTect 配置如下所示:
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<version>1.0.0.Beta1</version>
<executions>
<execution>
<id>add-module-info-to-dependencies</id>
<phase>package</phase>
<goals>
<goal>add-module-info</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/modules</outputDirectory>
<overwriteExistingFiles>true</overwriteExistingFiles>
<modules>
<module>
<artifact>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</artifact>
<moduleInfoSource>
module bcprov.jdk15on {
}
</moduleInfoSource>
</module> <!-- bcprov.jdk15on -->
<module>
<artifact>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</artifact>
<moduleInfoSource>
module com.fasterxml.jackson.core {
}
</moduleInfoSource>
</module> <!-- com.fasterxml.jackson.core -->
<module>
<artifact>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</artifact>
<moduleInfoSource>
module com.fasterxml.jackson.databind {
}
</moduleInfoSource>
</module> <!-- com.fasterxml.jackson.databind -->
<module>
<artifact>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</artifact>
<moduleInfoSource>
module hibernate.core {
}
</moduleInfoSource>
</module> <!-- hibernate.core -->
<module>
<artifact>
<groupId>io.sentry</groupId>
<artifactId>sentry</artifactId>
</artifact>
<moduleInfoSource>
module io.sentry {
}
</moduleInfoSource>
</module> <!-- io.sentry -->
<module>
<artifact>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
</artifact>
<moduleInfoSource>
module java.persistence {
}
</moduleInfoSource>
</module> <!-- java.persistence -->
<module>
<artifact>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</artifact>
<moduleInfoSource>
module java.validation {
}
</moduleInfoSource>
</module> <!-- java.validation -->
<module>
<artifact>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</artifact>
<moduleInfoSource>
module org.apache.commons.lang3 {
}
</moduleInfoSource>
</module> <!-- org.apache.commons.lang3 -->
<module>
<artifact>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</artifact>
<moduleInfoSource>
module spring.core {
}
</moduleInfoSource>
</module> <!-- spring.core -->
<module>
<artifact>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</artifact>
<moduleInfoSource>
module spring.web {
}
</moduleInfoSource>
</module> <!-- spring.web -->
<module>
<artifact>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</artifact>
<moduleInfoSource>
module spring.boot {
}
</moduleInfoSource>
</module> <!-- spring.boot -->
<module>
<artifact>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</artifact>
<moduleInfoSource>
module spring.context {
}
</moduleInfoSource>
</module> <!-- spring.context -->
<module>
<artifact>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</artifact>
<moduleInfoSource>
module spring.data.commons {
}
</moduleInfoSource>
</module> <!-- spring.data.commons -->
<module>
<artifact>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</artifact>
<moduleInfoSource>
module spring.data.jpa {
}
</moduleInfoSource>
</module> <!-- spring.data.jpa -->
<module>
<artifact>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</artifact>
<moduleInfoSource>
module spring.security.core {
}
</moduleInfoSource>
</module> <!-- spring.security.core -->
<module>
<artifact>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</artifact>
<moduleInfoSource>
module spring.tx {
}
</moduleInfoSource>
</module> <!-- spring.tx -->
<module>
<artifact>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</artifact>
<moduleInfoSource>
module spring.webmvc {
}
</moduleInfoSource>
</module> <!-- spring.webmvc -->
<module>
<artifact>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</artifact>
<moduleInfoSource>
module tomcat.embed.core {
}
</moduleInfoSource>
</module> <!-- tomcat.embed.core -->
</modules>
</configuration>
</execution>
<execution>
<id>create-runtime-image</id>
<phase>package</phase>
<goals>
<goal>create-runtime-image</goal>
</goals>
<configuration>
<modulePath>
<path>${project.build.directory}/classes</path>
<path>${project.build.directory}/modules</path>
</modulePath>
<modules>
<module>tech.flexpoint.dashmanserver</module>
</modules>
<launcher>
<name>dashmanserver</name>
<module>tech.flexpoint.dashmanserver</module>
</launcher>
<outputDirectory>
${project.build.directory}/jlink-image
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

如果我添加
<path>c:\Users\pupeno\.m2\repository\tech\flexpoint\dashmancommon\1.0.0-beta.11</path>

到我的 ModiTect 配置,它开始工作,生成这个命令行:
C:\Program Files\Java\jdk-10.0.1\bin\jlink --add-modules tech.flexpoint.dashmanserver --module-path c:\Users\pupeno\.m2\repository\tech\flexpoint\dashmancommon\1.0.0-beta.11;C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\modules;C:\Program Files\Java\jdk-10.0.1\jmods;C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\classes --output C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\jlink-image --launcher dashmanserver=tech.flexpoint.dashmanserver

我想这证实了该模块的工作原理并已安装。我只是不确定如何让 ModiTect 找到它(没有可怕的硬编码路径)。

最佳答案

我认为您的问题对应于 this moditect 的已知问题。
当前不支持从碰巧已经是模块的 maven 依赖项子集生成模块路径。解决方法是使用 maven-dependency 插件将它们复制到可以添加到模块路径的已知目录中。

关于java - ModiTect 和 Jlink 找不到模块依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49716711/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com