Setup Project in STS

Spring Tool Suite is one of most popular IDEs for Java developers to develop Spring-based applications. If you don't have STS in your machine, first download the latest version of STS from the following link:

Let's create a new Spring Boot application in the STS

  • Select New | Spring Starter Project menu item from the File menu as show below :
Fig : Spring Starter Project
  • As you click on Spring Starter Project, STS will present you with a dialog box as shown below:
Fig : New Spring Starter Project

    This dialog box asks for the same information as the web-based Spring Initializr. So, fill it in with the same information, as we filled in the web-based Spring Initializr.

  • Click the Next button. It will present us with a another dialog box like the one shown below :
Fig : Project Dependencies

    In this dialog box, you can add dependencies as per your project need. For example, If you want to develop a web application, you can add web dependencies, devtools to pick up the changes and restart the application, my-sql or H2 dependencies for database.

  • Finally, click on the Finish button.
  • As you click on Finish button, a project structure will get created in your workspace with default files and folders.

You must be connected to the internet in order for it to work, because STS internally delegates to the Spring Initializr at to produce the project.

Now that the project has been imported into your workspace. The structure of the project looks like below image :

Fig : Project Structure

As you can see, there's very little code in this project and it also creates a couple of empty directories. The generated project contains the following:

  • pom.xml : A Maven build specification which contain all the dependencies of project.
  • : A class with a main() method to bootstrap the application.
  • : An empty JUnit test class instrumented to load a Spring application context using Spring Boot auto-configuration.
  • : An empty properties file for you to add configuration properties.
  • static directory : Here, you can put any static content (JavaScript, style sheets, images, and so on) to be served from the web application.
  • templates directory : Here, you can put templates that render model data.