0% found this document useful (0 votes)
8 views13 pages

Spring Boot

This document provides a step-by-step guide for configuring a Spring Boot project using JDK 17 and Eclipse. It includes instructions on setting up project metadata, importing the project into Eclipse, and creating a simple REST web service with a controller class. Additionally, it emphasizes the importance of checking for errors during setup and provides a homework link for further learning about Spring Boot.

Uploaded by

techtrillion7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views13 pages

Spring Boot

This document provides a step-by-step guide for configuring a Spring Boot project using JDK 17 and Eclipse. It includes instructions on setting up project metadata, importing the project into Eclipse, and creating a simple REST web service with a controller class. Additionally, it emphasizes the importance of checking for errors during setup and provides a homework link for further learning about Spring Boot.

Uploaded by

techtrillion7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

SpringBoot-JBKADVSPRINGBOOT3001 thekiranacademy.

com 8888809416

Spring boot First Example


with configurations.

We need to follow some steps to configure spring boot project.

Pre-Requisite:

• Jdk 17
• Latest eclipse
• MySQL – required in future.
To install java and eclipse, follow this document, if you already have latest eclipse and java 8
skip this step.

https://javabykiran.in/core-java/JBKSETUP001-java-eclipse-setup.pdf

Step #1

Open website https://start.spring.io/

Select below details.

pg. 1
SpringBoot-JBKADVSPRINGBOOT3001 thekiranacademy.com 8888809416

Project Metadata

• Group
o This is a folder where all other spring boot project you want to store.
o enter com.javabykiran
• Artifact
o Your current project name.
o enter basicMicroserviceProject
• Name
o Any name
• Description
o First basic microservice or REST webservice project
• Package name

pg. 2
SpringBoot-JBKADVSPRINGBOOT3001 thekiranacademy.com 8888809416

o com.javabykiran.controller
• Packaging
o war: This is to create web project.
o jar: This is to create API project.
o select jar.
• Java
o version 17 we will be using.
o version 17

Click on dependencies.

Add web , devtools

pg. 3
SpringBoot-JBKADVSPRINGBOOT3001 thekiranacademy.com 8888809416

Step #2

Extract project

Step #3

Import project to eclipse.

pg. 4
SpringBoot-JBKADVSPRINGBOOT3001 thekiranacademy.com 8888809416

pg. 5
SpringBoot-JBKADVSPRINGBOOT3001 thekiranacademy.com 8888809416

Once you click on Select Folder you can see pom.xml will be imported.

pg. 6
SpringBoot-JBKADVSPRINGBOOT3001 thekiranacademy.com 8888809416

Once click on finish. Wait for dependencies to get downloaded in our project. It
may take few minutes depending upon your internet speed.

Below is project structure after downloading all dependencies. Make sure you
do not have any errors in problem windows. Most of the errors occur if we do
not have proper version of java or maven or eclipse.

Open problem window – window – show view - problems.

pg. 7
SpringBoot-JBKADVSPRINGBOOT3001 thekiranacademy.com 8888809416

Step #4

Check if out setup is correct.

This is important window as below. For everything you do in eclipse always


keep this window open for seeing any errors.

pg. 8
SpringBoot-JBKADVSPRINGBOOT3001 thekiranacademy.com 8888809416

Just for time being we will see how errors will look like.

Step #5

It’s time to check if our spring boot project is running correctly.

After running this console should have below output.

pg. 9
SpringBoot-JBKADVSPRINGBOOT3001 thekiranacademy.com 8888809416

Now it is time to write simple


first webservice.
Step #6
1. Create controller class.
a. This is a class which will be hit by client first.
b. This class takes a request and send response back to client.
i. Response can be json or xml format.
ii. Our focus will be on json format.
2. Use all annotations required for rest API.
a. @Restcontroller
i. This annotation is used at class level.
ii. This is mandatory if we want to create rest webservice.
b. @Requestmapping
i. @getMapping
ii. @postMapping
iii. @putMapping
iv. etc.

pg. 10
SpringBoot-JBKADVSPRINGBOOT3001 thekiranacademy.com 8888809416

Step #7

Create CustomerController.java as below.

We have not yet added endpoint for our service. So add at method level @RequestMapping
annotation

Go to browser. This is simple service we have created we need to run this


service.

First start a project from main method.

pg. 11
SpringBoot-JBKADVSPRINGBOOT3001 thekiranacademy.com 8888809416

Check console if you see any exceptions if not go to browser.

In address bar hit url http://localhost:8080/firstservice

pg. 12
SpringBoot-JBKADVSPRINGBOOT3001 thekiranacademy.com 8888809416

Summary

Homework:

Read tutorial from below link to know in depth of spring boot. Screens used might be different
than this, but concept is same.

https://www.jbktutorials.com/spring-boot/introduction-to-spring-boot.php#gsc.tab=0

pg. 13

You might also like