Eclipse中提示Could not find the main class之解决方法

时间:2024-03-21 17:19:23

在Eclipse中调试代码,进行Maven clean和Maven update后,突然报了这么一个错:Could not find the main class。没有找到主类!之前调试还好好的啊!
运行方法和之前一样,就是在main class进行右键点击Run As->Java Application,怎么突然找不到主类了?尝试删除其他无关的类和代码,尝试无效。
Eclipse中提示Could not find the main class之解决方法
解决方法: 点击绿色运行按钮右边的下拉小箭头,去选择Run Configurations…中删除同名的类即可。
Eclipse中提示Could not find the main class之解决方法
删除红色箭头指示的红框内的Main class。
Eclipse中提示Could not find the main class之解决方法
问题原因: Eclipse对于同一个项目,同一个类,当运行调试过一次之后它是有记忆的,所以当切换了新的分支,再次运行同一个类的时候,它默认会去找上一次运行时的一些信息,包括去哪找class文件。

可参阅:https://www.caogenjava.com/detail/101.html