Spring Boot – Starter Project

In this lesson we would go through how to create a Spring Starter Project. But first, we need to set up the Spring IDE.

 

  1. Download and Install Spring-Tool-Suite(sts)
  2. Create a New Starter Project
  3. Examine the main class
  4. Examine the pom.xml File

 

1. Download and Install Spring-Tool-Suite(sts)

First download Spring sts:

Download for Windows Spring sts  Download for Mac Download for Linux

If you downloaded for Windows (64 bit), then you will have it as a zip file.

Unzip the file into your drive C.

Open the file and locate the STS.exe file and open it (you can add a shortcut to your desktop)

If you followed the procedure, then you will have the interface as shown below:

 

Spring Boot Interface

 

2. Create a new Starter Project

Click on File

Select New and Choose Spring Starter project (Look at the figure below)

 

 

The New Spring Starter Project dialog box is shown as below.

So you can change the field marked in red if you want (or you can use the values in used)

 

 

After you have completed the fields in red, just click Next. The next  dialog allows you to select dependencies.

Under Available, enter web. Then select the web check box. We need this because we want to create a web application

Then remove web and enter jpa. Next select the jpa checkbox. This would add dependency that enables us connect to database.

You dialog box would be as shown below (without the Frequently Used section)

 

 

Go ahead to click on finish

After some seconds, your project would be set up. (ensure your computer is connected to the internet)

At the left side, under Package Explorer, you can see your project. Expand it as shown in the Figure below.

Then open the FirstAppApplication.java file

 

 

 

3. Examine the Main Class File

The FirstAppApplication.java file is the main class file.

Check that the content is as shown below

You can refer to Tutorial 1(Spring Boot Introduction) to understand the @SpringBootApplication annotation

The SpringApplicaiton.run() method tells Spring Boot to bootstrap the application from this class.

 

package com.kindsonthegenius.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class FirstAppApplication {

	public static void main(String[] args) {
		SpringApplication.run(FirstAppApplication.class, args);
	}

}

 

4 .Examine the pom.xml File

Open the pom.xml file

Check that the pom.xml file contains the following dependencies. You can find the two dependencies you selected during startup (web and jpa)

 

<dependencies>

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-data-jpa</artifactId>
	</dependency>
	
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-web</artifactId>
	</dependency>

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-test</artifactId>
		<scope>test</scope>
	</dependency>
	
</dependencies>

 

Now we have set up our application.

In the next lesson we would add a REST endpoint, deploy and run the application.