找不到模块xxx,xxx要求

问题描述

我正在尝试使用Java14在Eclipse 2020-06中构建一个小程序我有Guava 29作为依赖项。这是我的module-info.java

module xxx {

   exports main;

   requires java.base;
   requires java.desktop;
   requires java.prefs;
   requires com.google.common;
}

但是,当我启动程序时,会收到以下消息:

Error occurred during initialization of boot layer
java.lang.module.FindException: Module com.google.common not found,required by xxx

番石榴罐位于Modulepath下。我没有使用Maven等任何构建工具。


删除requires之后,我检查了编译器的建议。这是编译器建议的要求,但我以前已经有过。 参见:https://prnt.sc/unp2hf

解决方法

我找到了解决问题的方法。首先,将依赖项移至名为 项目根文件夹中的 模块 。然后将它们添加到模块路径。

enter image description here

然后,在同一窗口中,单击“源”,然后将“默认输出文件夹”编辑为

PROJECT_NAME /模块/ MODULE_NAME

enter image description here

并愉快地启动该程序。