简体   繁体   English

错误:无法在Spring STS中为Spring BOOT项目找到或加载主类

[英]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". 尝试清洁项目并提供多个版本,但出现“错误:找不到或加载主类”。

  • I changed STS workspace 我改变了STS工作区
  • I have given maven build 我给了Maven build
  • No such compilation error 没有这样的编译错误
  • JDK 8 installed in my machine 我的机器上安装了JDK 8

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帮助的控制台选项卡旁边。

  1. In short stop IDE 简而言之,IDE
  2. either remove .m2 folder or remove specific dependencies under .m2 if you know which is problematic. 如果您知道哪个问题,请删除.m2文件夹或删除.m2下的特定依赖项。
  3. restart 重新开始
  4. IDE right click project and maven update IDE右键单击项目并进行Maven更新

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Gradle、Spring 开机。 错误:无法找到或加载主 class - Gradle, Spring boot. Error: Could not find or load main class 如何解决在 spring 引导时找不到或加载主 class 错误? - How to solve could not find or load main class error with spring boot? Spring Boot 模块中的“错误:无法找到或加载主类” - "Error: Could not find or load main class" in a Module of Spring Boot “Spring Boot Project”错误:无法找到或加载主 class fyp.fms.FleetManagementSystemApplication - “Spring Boot Project” Error: Could not find or load main class fyp.fms.FleetManagementSystemApplication 运行spring boot应用程序时找不到或加载主类 - Could not find or load main class, when running spring boot Application 运行spring boot jar时找不到或加载主类 - Could not find or load main class, when running spring boot jar Spring boot gradle“无法找到或加载主类” - Spring boot gradle "Could not find or load main class" 错误:无法在Spring Boot 1.5.9版本中找到或加载主类…,但是在1.4.7版本中找不到 - Error: Could not find or load main class … in Spring Boot 1.5.9 version but not in 1.4.7 错误:无法找到或加载主类 Maven Spring Boot 应用程序 - 可执行 JAR - Error: Could not find or load main class Maven Spring Boot Application - Executable JAR Eclipse STS 4 错误:无法找到或加载主类 - Eclipse STS 4 Error: Could not find or load main class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM