Create a Rest API with Spring Boot

Hi there, my name is Muzaffer Arda Uslu. I am a computer engineer student at Eskişehir Osmangazi University. I have been learning JAVA for two months. Now, I’m gonna try to explain how to create a simple Spring Boot Project.

Muzaffer Arda Uslu
Oct 7, 2020 · 3 min read

Main Goal is:

  • Create a Spring Boot Project
  • To learn using annotations such as @Repository, @Service, @RestController, @GetMapping, @PostMapping, @DeleteMapping, @PutMapping

How to Create a Spring Starter Project?

File -> New -> Spring Starter Project

as shown below.

After creating project let’s code!

1- Model Package

Student.java

Course.java

2- Repository Package

StudentRepo.Java

CourseRepo.java

3- Service Package

StudentService.java

CourseService.java

4- Controller Package

We can use all HTTP Request with @Restcontroller.

StudentController.java

CourseController.java

https://www.postman.com/
I use Postman to send request.

Let’s Run The Application and Test HTTP Requests

{
"id": 125,
"studentName": "Arda",
"courses":[
{
"courseName": "Math"
}
]
}
  • Course in JSON Format:
{
"courseName": "English"
}

1- Post Method

2-Get Method

3-Put Method

4-Delete Method

You can test the other endpoints. You can also change the endpoints and make practise.

GitHub Repo is here:

Bilgisayar ve Bilişim Teknolojileri Kulübü

Bilgisayar ve Bilişim Teknolojileri Kulübü Medium Yayını

Bilgisayar ve Bilişim Teknolojileri Kulübü

Bilgisayar ve Bilişim Teknolojileri Kulübü bünyesinde yapılan programlama eğitimlerin yürütücüleri tarafından hazırlanan yazılar.

Muzaffer Arda Uslu

Written by

Eskişehir Osmangazi University Computer Engineering Student. https://www.linkedin.com/in/muzafferardauslu/ https://github.com/ardasdasdas

Bilgisayar ve Bilişim Teknolojileri Kulübü

Bilgisayar ve Bilişim Teknolojileri Kulübü bünyesinde yapılan programlama eğitimlerin yürütücüleri tarafından hazırlanan yazılar.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store