当前位置:网站首页>IDEA 找不到或无法加载主类 或 Module “*“ must not contain source root “*“ The root already belongs to module “*“
IDEA 找不到或无法加载主类 或 Module “*“ must not contain source root “*“ The root already belongs to module “*“
2022-08-01 01:17:00 【Apple-yeran】
今天用IDEA写代码,运行时总是提示错误:找不到或无法加载主类,百度谷歌尝试了所有方法,都不能解决,很抓狂。
静下心来思考一会儿之后,点击IDEA项目下的out/production目录,发现了问题:
之前的module编译之后左边都有一个箭头,说明里面有文件(.class文件),但是出问题的module,也就是Day15_exception是没有箭头的,说明编译生成的字节码文件没有到这个目录下,于是又检查了一遍IDEA路径,发现都没有问题,这让我更加困惑。
突然想到了我最开始建立module时,module名字是Day15_exception,并且编写代码运行了,后来发现和自己之前的命名习惯不同(首字母大写),然后就重新改了,变成Day15_Exception,如下图所示:
但是out/production目录中的名字还是Day15_exception,于是将out/production下的名字改成Day15_Exception,但还是不行!!!
更加抓狂了!!!
又捣鼓了一会儿,觉得还是路径问题,于是把Day15_Exception这个module的路径从继承项目的路径改为手动设置路径,如下图所示:
点击apply,出现下图的错误:
意思是说JavaSE这个模块不能包含源根节点Day15_Exception\src,这个根节点已经属于Day15_Exception模块了,解决方法如下:
最后点击apply,ok,重新运行,即可正常运行。
总结:IDEA中的编译输出路径
IDEA默认编译输出路径是继承项目的路径:
项目的路径:
所以默认情况下,子模块中java文件编译生成的字节码文件在项目路径\production\module路径中,其中production是自动生成的。例如Day15_Exception模块中java文件编译生成的字节码文件位于:D:\Java\JavaSE\out\production\Day15_Exception\各级包名\MainClass.class。
当然也可以不使用默认路径(继承项目的路径),而是自己设置路径,如下图所示:
推荐:使用默认的继承项目路径即可。
边栏推荐
- MYSQL经典面试题
- OSD读取SAP CRM One Order应用日志的优化方式
- LeetCode每日一练 —— 环形链表问题(面试四连问)
- MVCC总结
- You need to know the TCP wave four times
- Rainbow share | how to use moving targets defense technology to guard against the unknown
- Carefully summarize thirteen suggestions to help you create more suitable MySQL indexes
- /usr/sbin/vmware-authdlauncher: error while loading shared libraries: libssl.so.1.0.2*解决办法
- Fat interface in JQESAP system
- MYSQL Keyword Explain Analysis
猜你喜欢

VPGNet

Unity3D study notes 10 - texture array

Four ways the Metaverse is changing the way humans work

ECCV2022 Workshop | Multi-Object Tracking and Segmentation in Complex Environments

Key Points Estimation and Point Instance

JVM面试题总结(持续更新中)

leetcode:1562. 查找大小为 M 的最新分组【模拟 + 端点记录 + 范围合并】

RTL8762DK UART(二)

MYSQL索引解析

MYSQL Index Analysis
随机推荐
MYSQL查询截取优化分析
WAASAP WebClient UI页面标签的决定逻辑介绍
二叉树遍历非递归程序 -- 使用栈模拟系统栈
Web API 介绍和类型
Item 36: Specify std::launch::async if asynchronicity is essential.
C字符串数组反转
Inheritance Considerations
zeno使用方法笔记
Inheritance and friend, static member relationship
Likou Binary Tree
WindowInsetsControllerCompat is simple to use
Fat interface in JQESAP system
Nmap 操作手册 - 完整版
Rainbow share | how to use moving targets defense technology to guard against the unknown
Data Middle Office Construction (VII): Data Asset Management
500 miles
MVCC总结
Nmap Operation Manual - Full Version
Matlab/ArcGIS processing GPM global monthly precipitation data
Design the message queue storage MySQL form of message data