让我们考虑以下情况。我有两层:
启动层是mycustom层的父级。我旁边有三个模块:
在mod.a的module-info中我有
module mod.a {
requires mod.b;
}
在mod.c的module-info中我有
module mod.c {
requires mod.b;
}
在启动层,我有mod.a和mod.b.在mycustom层我有mod.b和mod.c(由于某些原因,我希望在这个层中有mod.b)。但是,我得到以下异常:
java.lang.module.ResolutionException:mod.c读取多个名为mod.b的模块。
是否可以隐藏"在mycustom层中的模块的启动层中的mod.b?如果是,那怎么样?
这是我创建mycustom图层的方式:
ModuleFinder finder = ModuleFinder.of(...);
ModuleLayer parent = ModuleLayer.boot();
Configuration cf = parent.configuration().resolve(finder, ModuleFinder.of(), Set.of("mod.b, mod.c"));
ClassLoader scl = ClassLoader.getSystemClassLoader();
ModuleLayer myCustomLayer = parent.defineModulesWithOneLoader(cf, scl);