编程语言
首页 > 编程语言> > java – generate-module-info jdeps时缺少依赖项

java – generate-module-info jdeps时缺少依赖项

作者:互联网

我正在尝试使用以下命令运行jdeps:

jdeps --module-path modules --generate-module-info out com.demo.market.jar

我的com.demo.market.jar取决于应用程序模块和自动模块.
我把所有依赖项放在’modules’文件夹中,但是我收到了一个错误:

Error: missing dependencies
com.demo.market.platform.MarketPlace ->  com.demo.client.wholesale.Client  not found
com.demo.market.platform.MarketPlace ->  com.demo.product.api.Product      not found
com.demo.market.platform.MarketPlace ->  com.demo.product.laptop.Laptop    not found
com.demo.market.collector.ProductsCollector -> com.demo.logistic.DeliveryService not found
com.demo.market.collector.ProductsCollector -> com.demo.product.api.Product      not found

但是当我添加–add-modules它工作正常.

jdeps --module-path modules --add-modules com.demo.client,com.demo.product,com.demo.logistic --generate-module-info out com.demo.market.jar

难道我做错了什么?我认为jdeps会找到所有模块而不是手动添加它们.

解决方法:

执行以下操作时:

jdeps --module-path modules --generate-module-info out com.demo.market.jar

从目录中解析的模块是可观察的模块,在您的情况下,它们无法进入根模块集.

在问题的其他部分 –

jdeps --module-path modules --add-modules com.demo.client,com.demo.product,com.demo.logistic --generate-module-info . com.demo.market.jar

另一方面,明确添加它们可确保模块存在于根模块集中.

作为替代方案(从JEP261#Module System开始,您可以尝试使用该命令

jdeps --module-path modules --add-modules=ALL-MODULE-PATH --generate-module-info out com.demo.market.jar 

As a final special case, at both run time and link time, if is ALL-MODULE-PATH then all observable modules found on the relevant
module paths are added to the root set. ALL-MODULE-PATH is valid at
both compile time and run time. This is provided for use by build
tools such as Maven, which already ensure that all modules on the
module path are needed. It is also a convenient means to add automatic
modules to the root set.

关于要执行的命令,请注意: –

>此外,问题中共享的jdeps输出与-verbose:class理想地成立.

标签:jdeps,java,java-9,jigsaw
来源: https://codeday.me/bug/20191001/1840439.html