当前位置:网站首页>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。
当然也可以不使用默认路径(继承项目的路径),而是自己设置路径,如下图所示:
推荐:使用默认的继承项目路径即可。
边栏推荐
- Super like the keyboard made from zero, IT people love it
- Rasa 3.x Study Series - Rasa - Issues 4898 Study Notes
- Nmap Operation Manual - Full Version
- Key Points Estimation and Point Instance
- Item 36: Specify std::launch::async if asynchronicity is essential.
- Force buckle 2326, 197
- Beijing suddenly announced that yuan universe big news
- 【数据分析】基于matlab GUI学生成绩管理系统【含Matlab源码 1981期】
- Rasa 3.x 学习系列-使用查找表改进实体提取
- Qlib quantitative source analysis: qlib/qlib/contrib/model/GBDT py
猜你喜欢
随机推荐
MVCC总结
date command
设计消息队列存储消息数据的MySQL表格
MYSQL关键字Explain解析
Detailed explanation of TCP protocol
Key Points Estimation and Point Instance
WindowInsetsControllerCompat is simple to use
Introduction to the five data types of Redis
Carefully summarize thirteen suggestions to help you create more suitable MySQL indexes
欧拉系统(euleros):升级Mysql
qlib量化源码分析:qlib/qlib/contrib/model/gbdt.py
如何编辑epub电子书的目录
Key Points Estimation and Point Instance
What practical projects can machine learning beginners learn?
ECCV2022 Workshop | 复杂环境中的多目标跟踪和分割
Rasa 3.x Study Series - Rasa - Issues 4918 Study Notes
[Microservice] Distributed Transaction Solution - Seata
Academicians of the two academies speak bluntly: Don't be superstitious about academicians
Automated machine learning pycaret: PyCaret Basic Auto Classification LightGBM
Binary tree traversal non-recursive program -- using stack to simulate system stack








![[AMEX] LGBM Optuna美国运通信用卡欺诈赛 kaggle](/img/64/55af53a3d9dc1162490d613fe8a436.png)
