Search code examples
springspring-bootspring-tool-suitespring-starter

Why does STS show compilation errors when I first create a skeleton Boot project?


I just downloaded and installed Spring Tool Suite 4 for Mac. It has the following version ...

Version: 4.6.2.RELEASE Build Id: 202005250833

I created a brand new Spring Boot project by going to the File menu, selecting "New" and then "Spring Starter Project." I filled out the information on the next screen, and then selected Spring Boot 2.3.1. When I open up the resulting scaffolding, though, there are already compilation errors ...

enter image description here

When I go to my "Run" menu and select "Run As" -> "Spring Boot App," the following error appears

Error: Could not find or load main class com.burrobuie.cardmania.CardmaniaApplication

Is there something else that needs to be done so that there are no compilation errors in my project when it is first created? I feel like this is something that should be the default behavior.


Solution

    1. In top of STS you see File Edit Navigate Search Project
    2. Click on Project -> clean -> select your project -> check Build automatically
    3. Click on Project -> clean -> select your project -> clean
    4. Look for the pom file of your project
    5. Right click on pom file -> maven -> update project.
    6. Right click on pom file -> run as -> maven build -> goals: enter'clean install' -> run
    7. In the console you should see build success.

    your compilation errors will be all gone. Not all these steps are required to do every time it only when you see compilation error performing one or all the steps will resolve the issue.