[英]Error: Could not find or load main class in Spring STS for Spring BOOT project
Tried cleaning projects and giving multiple builds but I am getting "Error: Could not find or load main class". 尝试清洁项目并提供多个版本,但出现“错误:找不到或加载主类”。
But I am getting the error when I am running Application.java class 但是我在运行Application.java类时遇到错误
Please help me out. 请帮帮我。
I faced the same issue.. 我遇到了同样的问题。
just do follow these steps: 请按照以下步骤操作:
STS --> Project --> Enable "Build Automatically" STS->项目->启用“自动构建”
then refresh your project, it will resolve your issue. 然后刷新您的项目,它将解决您的问题。
Still not refreshed your projects automatically, just restart your STS and check. 仍然没有自动刷新您的项目,只需重新启动STS并检查即可。
Hope it will help you. 希望对您有帮助。 Happy reading.!!! 阅读愉快!!!
Look at the problems tab and see some of the jars under .m2 might be complaining. 查看问题选项卡,查看.m2下的某些jar可能在抱怨。 In my case spring-boot-autoconfigure jar was a problem. 就我而言,spring-boot-autoconfigure jar是个问题。
navigated to user C:\\Users[your user].m2\\repository\\org\\springframework\\boot 导航到用户C:\\ Users [您的用户] .m2 \\ repository \\ org \\ springframework \\ boot
renamed folder spring-boot-autoconfigure 重命名文件夹spring-boot-autoconfigure
right click on project go to maven 右键单击项目转到Maven
click update 点击更新
and problem disappears 问题消失了
some solutions suggest that the main class not found problem occurs due to any conflicting jar or corrupted jar file which is true but unfortunately as long as I found they suggest to remove .m2 folder altogether. 一些解决方案表明,由于存在任何冲突的jar或损坏的jar文件,这是真实的,但是不幸的是,只要我发现他们建议完全删除.m2文件夹,就会出现未找到主类的问题。 Though it may resolve the issue but is time consuming because all the dependencies will be re-downloaded. 虽然它可以解决问题,但很耗时,因为所有依赖项都将重新下载。
That's why I was running after to find where is the root cause and problems tab which appears along side the console tab in STS and Eclipse helps. 这就是为什么我一直在寻找根本原因和问题选项卡的原因,该选项卡出现在STS和Eclipse帮助的控制台选项卡旁边。
Hope this helps 希望这可以帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.