0

When I create any project in SpringBoot the project appears an error saying the following: "Could not locate or load the main class". However, when I run any other old project it works normally.

  • Looks like something is wrong in your IDE. Try running your app from the command line – Federico Piazza Feb 06 '19 at 19:53
  • the same message appears. – Fabio Miranda Zanela Feb 06 '19 at 21:04
  • I created a new project, but the same was in version 2.1.2 RELEASE, in my other projects I was using version 2.0.6 RELEASE. When I changed to version 2.0.6 the project ran smoothly. – Fabio Miranda Zanela Feb 13 '19 at 20:55
  • create a project from https://start.spring.io/, unzip it and execute `mvn clean package` from the terminal. This should work perfectly well. If you face an issue then it's your environment. You can import later your project to your IDE and if it isn't working then you have issues in your IDE. – Federico Piazza Feb 14 '19 at 11:15
  • When I created the project from the site "https://start.spring.io/" the same problem occurred and the solution was to go back to the previous version. – Fabio Miranda Zanela Feb 14 '19 at 17:26
  • alright, then you have troubles in your local environment. What jdk are you using, try with jdk-8 which is pretty stable. Another thing you can do is to get rid of your `.m2` spring directory. You might have had an issue the first time and your local jar could be borked. You can try `mvn dependency:purge-local-repository`, and then run a `mvn clean package` for your project with spring 2.1 – Federico Piazza Feb 14 '19 at 19:03
  • Cleaning the .m2 file has solved everything, now it is working normally. Many thanks for the help. – Fabio Miranda Zanela Feb 18 '19 at 21:30
  • ok. I'll post the answer so we can close this question – Federico Piazza Feb 18 '19 at 21:48

2 Answers2

0

Right Click on your project -> Maven -> Update Project...

Seemant Shukla
  • 619
  • 1
  • 7
  • 16
0

You might have had an issue the first time and your local jar could be borked, so it looks like your .m2 dependencies has downloaded incorrectly.

Execute mvn dependency:purge-local-repository to delete your local repository and then execute mvn clean package

Federico Piazza
  • 30,085
  • 15
  • 87
  • 123