idea中添加module-info.java
idea创建模块默认不会带module-info.java,添加方法src目录单击右键->new

Module is not in dependencies问题
module-info.java添加依赖模块时提示找不到依赖,需要在模块配置中增加依赖模块项,右键模块名->Open module Setting,如下图所示选择依赖模块

Kotlin standard library is not found问题
Error:Kotlin: The Kotlin standard library is not found in the module graph. Please ensure you have the ‘requires kotlin.stdlib’ clause in your module definition
运行多模块程序需要加入Kotlin库,添加方法

如果还有问题就在module-info.java中添加requires kotlin.stdlib;
InvalidModuleDescriptorException Main.class found in top-level directory问题
module-info文件与执行的Class文件不能再同一个目录,Class文件必须在module-info所处目录的子目录。
错误的层级关系

正确的层级关系

本文指导如何在IntelliJ IDEA中添加module-info.java,解决Module not in dependencies问题,处理Kotlin standard library未找到错误,并修正InvalidModuleDescriptorException关于Main类路径的常见问题。重点讲解正确模块组织和依赖配置方法。
2143

被折叠的 条评论
为什么被折叠?



