Spring Boot Project using Spring Starter Project Wizard

In my previous articles of Spring Boot,Β I have covered the introduction of Spring Boot , Its advantages, limitations, goals, features etc and the Key Components of the Spring Boot.

If you have not read my introduction article of Spring Boot, I would request you to take a look – Β Spring Boot Tutorial.

There exists following ways to create Spring Boot project. We can use any of below mentioned approach to create Spring Boot Application :

We have already covered in previous article about How to install and configure Spring Boot in eclipse IDE and develop the Spring Boot Maven project.

Now, We are going to cover the second way i.e. “Spring Starter Project Wizard” in this article. In our next articles, we will cover remaining ways to create Spring Boot Application.

Spring Boot Project using Spring Starter Project Wizard

We are using Eclipse IDE for the below example. It is very popular IDE for java projects. You can download it from here.

Let’s get started :

Step 1 : Create a new Spring Starter Project

Go to File >> New >> Spring Starter Project :

Spring Starter Project Wizard

Provide the required details about Project and click on Next:

Spring Starter Project Wizard

Now, search the webΒ in the dependencies and check theΒ Spring WebΒ dependency and click on Finish :

Spring Starter Project Wizard

Now, the Spring Boot Project is automatically created with the below pasted pom.xml file :

Spring Starter Project Wizard
Don’t worry about the error symbol shown in image, It is just my XML definition error. Nothing Important.

pom.xml :Β 

<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 
        https://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.8.RELEASE</version>
		<relativePath/>
		<!-- lookup parent from repository -->
	</parent>
	<groupId>com.example</groupId>
	<artifactId>springBootApp</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>springBootApp</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-web</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>

Also Spring Boot Starter wizard has also created the main app class for our Project :

Spring Starter Project Wizard

Step 2 :Β Create the controller for Hello World Example

Now, create class inside the src/main/java package in your project :

Spring Starter Project Wizard

Now,

  • Add theΒ @ControllerΒ annotation class level.
  • Create a method that returns String .
  • AddΒ @RequestMapping(“/”)Β andΒ @ResponseBodyΒ  annotation at this method.

Spring Starter Project Wizard

  • @ControllerΒ indicates that class is a Controller.
  • @RequestMappingΒ Β annotation maps HTTP requests to handler methods of controllers.
  • @ResponseBodyΒ is annotation which binds the method return value to the web response body.

Step 3 :Β Run the Application

Now we have completed all tasks so it’s time to test our application by running it :

Spring Starter Project Wizard

Output :Β 

Spring Starter Project Wizard

Conclusion

That’s all folks! In this article,Β  we have learnt How to develop the Spring Boot Application using ‘Spring Boot Starter Wizard’.

Newsletter Updates

Enter your name and email address below to subscribe to our newsletter

Leave a Reply