Spring Boot - MongoDB Tutorial | beginners |
SpringBoot Tutorial with MongoDB for beginners.
Let’s create a car rental web service:
1. Go to https://start.spring.io/ to generate your carrental SpringBoot project
2. Set project configuration :
* Choose Maven Project
* Give it a name (Artifact)
* Add Spring Web as dependencies (library)
* Add DevTools as dependencies
* Add spring data mongoDB as dependencies
* Generate the project
3. Download and unzip the project
4. Open the project
5. Create your model class Car with these attributes :
- String plateNumber;
- String brand;
- int price;
- Add annotations (@Id, @Document)
- Create getters and setters
- Create constuctor
6. Create CarRepository interface.
7. Create CarRentalService class with will contains endpoints :
- GET - /cars - getListOfCars()
- POST - /cars - addCar()
- GET - /cars/plateNumber - getCar()
8. Run a MongoDB docker image and map it to your local port :
- docker run -d -p 27017-27019:27017-27019 --name mongodb-carrental mongo:4.0.4
9. Run your application class.
10. Test your endpoints with Postman
You can check MongoDB database with these following commands :
- docker exec -it mongodb-carrental bash
- mongo
- show dbs
You can stop your MongoDB docker container and remove it with these commands :
- docker stop mongodb-carrental
- docker rm mongodb-carrental
Видео Spring Boot - MongoDB Tutorial | beginners | автора Создание чат-ботов: основы и практика для всех
Видео Spring Boot - MongoDB Tutorial | beginners | автора Создание чат-ботов: основы и практика для всех
Информация
4 декабря 2023 г. 2:27:26
00:16:07
Похожие видео



















![Webinar [ENG] | Cyber Fortresses of the Gulf: Assessing GCC's Digital Defenses](http://pic.rutubelist.ru/video/a5/68/a568827279cb7e6f815241ceeb4c382f.jpg?size=s)