Spring Boot – Spring Initializr

You can create a new Spring project using Spring Initializr. That is the name.

First, not hat the spelling, ‘Initializr’ is not a typo.

 

So what is Spring Initializr?

Spring Initializr is an online tool you can use to generate Spring Starter project. Then you can download the project and open it in your local IDE.

To use Spring Initializr, go to www.start.spring.io. The page is as shown below:

 

 

Leave the Generate a ‘Maven Project’ with ‘Java’.

Also leave the Spring Boot version the default value. The value at the time of this tutorial is 2.1.3.

 

Under the group enter com.tutorials (you can change it)

Under artifact, enter FirstApp (you can also change it)

When you are done, click on Generate Project

The zip file would be downloaded.

Unzip the zip file into.

Now you can open the sts IDE.

Go to File and choose New > Open Project.

Then navigate the to the folder that contains the downloaded project and select it

 

You can see that the project opens in sts. So in the Package Explorer, expand the project and open the pom.xml. The content should look like shown below:

 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.1.3.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.kindsonthegenius</groupId>
	<artifactId>demo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>demo</name>
	<description>Demo project for Spring Boot</description>

	<properties>
		<java.version>1.8</java.version>
	</properties>

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

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

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

</project>

 

Open the the FirstAppApplication.java File

Expand the src/main/java folder and locate the FirstAppApplication.java file (demoApplication.java)

Open it

Write this code inside the main method:

 

    System.out.print("Welcome to Spring Initializr");

 

The file should now look like this:

 

Click on Run in the menu.

Select Run As > Spring Application as shown below

 

 

The project would run, and you would have the output below. In the next tutorial, we would examine how to add REST endpoints.

 

Watch the Video Lesson