Загрузка...

Spring Boot & MongoDB Tutorial: Create a CRUD REST API

Build a Spring Boot REST API with MongoDB! This complete CRUD tutorial covers project setup, code, and API testing.

In this step-by-step guide, you'll learn how to develop a powerful, production-ready RESTful web service using the Spring Framework and connect it to a MongoDB NoSQL database. We go through every line of code, from the initial project setup on start.spring.io to testing each of our CRUD (Create, Read, Update, Delete) endpoints with Postman.

We'll even run into a common bug when updating documents and I'll show you exactly how to fix it!

🔧 What You Will Learn:

How to set up a Spring Boot project with Maven, Java 21, and the necessary dependencies (Spring Web, Spring Data MongoDB, Validation).

Creating a model class and mapping it to a MongoDB collection with the @Document annotation.

Configuring the connection to your MongoDB instance in application.properties.

Building the Repository, Service, and Controller layers.

Implementing all CRUD operations: POST, GET, PUT, and DELETE.

Using Postman to test your REST API endpoints thoroughly.

How Spring Data automatically handles ID generation and updates.

🔗 BONUS
💻 Get 3 Months of IntelliJ IDEA Ultimate for FREE: https://www.jetbrains.com/store/redeem/
👉 *Use Promo Code:* LearnWithIfte

✅ For branding and Business inquiries ► learnwithiftekhar@gmail.com
► Join Discord: https://discord.gg/JZmFvSxw

🎯🎯 *Subscribe to my Newsletter:* https://learnwithiftekhar.kit.com/

📘 Resources Mentioned:
🧑‍💻 Source Code: https://github.com/learnwithiftekhar/REST-APIs-with-Spring-Boot-and-MongoDB

🙊 Here are the tools and resources I use in my videos:

👉 Master programming by recreating your favorite technologies: https://app.codecrafters.io/join?via=learnwithiftekhar

► Tool that I use for screen recording:
CleanShot X for Mac
* cleanshot.sjv.io/bODOab

⛔ Background sound: https://share.epidemicsound.com/ia954g

💻 *Running Windows on Mac? Get Parallels Desktop with a 20% discount!*
👉 *Use code PARALLELS20 and grab it here:* https://parallels.sjv.io/bOVD3M

IDE I use for coding
* IntelliJ Idea Ultimate
* VsCode
* Sublime

🌐 Secure your connection with NordVPN: https://nordvpn.sjv.io/o4zYan

🤚 In case you want to contact me:
❌ My LinkedIn profile: https://www.linkedin.com/in/hossain-md-iftekhar/
❌ My X / Twitter profile: https://twitter.com/ifte_hsn
❌ Github: Github: https://github.com/learnwithiftekhar

*Note:* Some of the links in this description are affiliate links, and I may earn a small commission if you make a purchase through them. Thank you for your support.

⏰ Timestamps:
00:00 - Introduction & What We'll Build
00:31 - Project Setup on start.spring.io
02:21 - pom.xml Dependencies Explained
03:18 - Creating the Product Model with @Document & @Id
06:47 - Configuring MongoDB in application.properties
10:21 - Creating the MongoRepository Interface
11:58 - Building the Product Service Layer
15:17 - Creating the REST Controller with @RestController
16:12 - Implementing the POST Mapping (Create Product)
17:13 - Implementing GET Mappings (Get All & Get by ID)
19:48 - Implementing the PUT Mapping (Update Product)
21:50 - Implementing the DELETE Mapping (Delete Product)
22:44 Connect to MongoDB from IntelliJ IDEA
24:24 - First Test with Postman & Creating a Product
27:51 - Testing the GET Endpoints
28:49 - The Common Update Problem (Bug Alert!)
30:30 - Fixing the Update Logic in the Controller
31:31 - Final Test of PUT and DELETE Endpoints
33:23 - Conclusion

Видео Spring Boot & MongoDB Tutorial: Create a CRUD REST API канала Learn With Ifte
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять