MongoDB + Spring Boot 3 | Crash Course

Поділитися
Вставка
  • Опубліковано 8 лют 2025

КОМЕНТАРІ • 60

  • @BoualiAli
    @BoualiAli  2 роки тому +1

    Table of content
    00:00 Intro
    02:01 What is mongoDB
    03:54 The difference between SQL and NoSQL databases
    06:28 How to choose between SQL and NoSQL databases
    10:15 MongoDB UI tools
    11:25 Why using docker for development
    12:54 Create an empty docker compose file
    14:25 Mongo server (docker compose)
    18:46 Mongo express (docker compose)
    21:42 Run docker compose and test
    25:07 Collections and documents
    28:14 Create a new spring project
    31:56 Project structure
    34:08 Include docker compose file into the project
    37:38 Project architecture
    41:10 Connect to MongoDB
    44:34 Create a new database
    45:57 Explain ADMIN, CONFIG and LOCAL databases
    50:46 Create Java class
    54:23 Transform the Java class to a collection
    56:47 Create the mongo repository
    59:01 Insert the first data into collection
    01:04:48 Create the product service
    01:06:48 Save the product
    01:11:36 Find product by ID
    01:12:25 Find all products
    01:12:45 Delete products
    01:13:13 CRUD - Create product controller
    01:15:14 CRUD - Save product
    01:16:51 CRUD - Find all products
    01:17:48 CRUD - Find by ID
    01:19:16 CRUD - Delete product
    01:20:50 CRUD - Test operations
    01:27:06 Extend the product model
    01:29:47 Create Category java class
    01:31:33 Use category as a field
    01:34:09 Relationship between Product and category
    01:35:16 Transform Category to a collection
    01:36:11 Create a category repository
    01:36:57 Insert categories at startup
    01:38:51 The issue in linking collections
    01:42:08 Add relation between collections
    01:45:47 Add OpenApi dependency
    01:47:33 Test and play with swagger UI
    01:53:40 Continue learning

  • @srujanashankar9517
    @srujanashankar9517 3 місяці тому +1

    I really liked your voice. calm and easy on the ears.
    Good tutorial, thanks

  • @Dmitry-d9q
    @Dmitry-d9q Рік тому +3

    I've watched a lot of mongo db tutorials in English and Russian. I believe it is the best one for mongo db beginners

  • @annusssshka
    @annusssshka 11 місяців тому +1

    Thank you very much for this video!

    • @BoualiAli
      @BoualiAli  10 місяців тому

      You're very welcome!

  • @hazel-BKJ
    @hazel-BKJ 10 місяців тому

    Once again the content of your video allows me to move forward in my learning about the spring boot framework, in one of your videos you talked about database migrations and I then went deeper into the subject but it was with relational databases and here I'd like to know if it's possible to migrate non-relational databases, thank you Mr Ali.

  • @mukhammadnajimov8440
    @mukhammadnajimov8440 11 місяців тому

    Thank you @BoualiAli I always watch your tutorial
    and they are really helpful

    • @BoualiAli
      @BoualiAli  9 місяців тому

      Glad you liked it!

  • @waeljadla9688
    @waeljadla9688 2 роки тому

    Great job thanks a lot ye ghali ❤ ! The best 🥇🔝🔝

  • @boolhak
    @boolhak 2 роки тому

    ​thank you so much, you are the best

  • @ОлегЧуй-э8и
    @ОлегЧуй-э8и Рік тому +2

    Good video, but it seems to me that @DbRef annotation doesn't solve the problem u've described in section 'The issue in linking collections' 1:39:00. As I've noticed this annotation doesn't let u create a document with a child which doesn't have an id, but it still let u create a child which has a fake id.

  • @AmineCch2t
    @AmineCch2t 2 роки тому +1

    Hi, from Morocco, I hope you are doing great.
    I am about to create a chat app using Spring boot and MongoDB, I want to explore MongoDB's Tailable option, my app will also have desktop notifications.
    By the way, your spring security tutorial is very interesting

    • @BoualiAli
      @BoualiAli  2 роки тому

      Thank you for your feedback.

  • @Andrey198923
    @Andrey198923 Рік тому

    good tutorial

  • @amenajroud6551
    @amenajroud6551 2 роки тому

    Thx a lot Ali

  • @ArunKumar-tr7ql
    @ArunKumar-tr7ql 2 роки тому

    Bouali it's request, good to have all your contents in English which we all will get reached to it.

    • @BoualiAli
      @BoualiAli  2 роки тому +1

      This is the plan. I'm doing all the new videos in english

  • @loshithahasaral3273
    @loshithahasaral3273 2 роки тому

    Thank you very much

  • @SameeraSenarathna
    @SameeraSenarathna 9 місяців тому

    Thank you

  • @nick-sx2zn
    @nick-sx2zn 4 місяці тому

    any written version for the tutorial?

  • @ziadghouzlani4220
    @ziadghouzlani4220 Рік тому

    Hey Ali , thank you for this great resource , have you ever worked with elasticsearch api ? Do we need to follow the same approach in this video?

    • @BoualiAli
      @BoualiAli  Рік тому

      I never worked with it, so I can’t tell if it is the same approach or not

  • @codertravel99
    @codertravel99 9 місяців тому

    can you please create one session for MongoDB usage with spring boot data mongo for file upload and best practice for file upload if we are not using aws s3 in that case and also how to write custom implementation for mongodb in spring boot 3 or anything so that we can aware of that.

    • @BoualiAli
      @BoualiAli  9 місяців тому

      I already implemented file upload in my previous video. check it

  • @daoudasylla91
    @daoudasylla91 2 роки тому

    Thank you Ali for this tuto. Tell me, wictch theme do you use ? I like you intelliJ interface.

    • @BoualiAli
      @BoualiAli  2 роки тому

      The new ui from the latest version of intellij

    • @daoudasylla91
      @daoudasylla91 2 роки тому

      @@BoualiAli ok thanks

  • @NomadicAlfa
    @NomadicAlfa Рік тому +1

    Getting an error at 1:03:20 , it says that it failed to execute CommandLineRunner , Exception executing Mongo credentials, Authentication failed on server

    • @BoualiAli
      @BoualiAli  Рік тому

      You have bad credentials to acces your mongo

    • @NomadicAlfa
      @NomadicAlfa Рік тому

      @@BoualiAli how to solve this issue?

    • @BoualiAli
      @BoualiAli  Рік тому

      @@NomadicAlfa set the correct credentials

    • @cevaponomaryov9044
      @cevaponomaryov9044 Рік тому

      Dear friend, I ran into a similar problem and found a solution, All because you create your database before launching the application and because your data for authentication is not there, you have two solutions just delete the database and then it will work in the compilation process, or use this code in the database console:
      use myDB
      db.createUser(
      {
      user: "username",
      pwd: "password",
      roles: [ { role: "readWrite", db: "myDB" } ]
      }
      )

    • @milaaaa9426
      @milaaaa9426 2 місяці тому

      if anyone still has this problem you can replace the content in the application.yml with this
      spring:
      data:
      mongodb:
      uri: mongodb://[username]:[password]@localhost:27017/[yourDb]?authSource=admin

  • @StefanoPeciarolo
    @StefanoPeciarolo Рік тому

    MongoExpress doesn't update the list of collections in the database so I don't see Product, whereas if I connect with MongoDB Compass I see both the collection and the data

    • @scholarway
      @scholarway Рік тому

      At first glance, I thought it was an issue. However, after two days of thorough investigation, I realized the importance of deleting all MongoDB-related data on the localhost. This step was crucial even after reinstalling Docker and MongoDB Community Edition. It was only after creating a new user and database that I finally saw the solution.

  • @wmjabeen
    @wmjabeen 11 місяців тому

    I will be using the IntelliJ plugin for Mongo, Do I still need to create the container for mongo-express or I can skip that?

    • @BoualiAli
      @BoualiAli  9 місяців тому

      you can skip that

  • @KuldeepKumar-ki6cu
    @KuldeepKumar-ki6cu 2 роки тому

    Hello Sir , I am a college student from India ... Hope you are well ... I am working an andorid(JAVA) project like whatsapp which has feature of private chatting I unable to find the great resources could you please make a video in short how to do this...please sir

  • @kahlilkahlil9172
    @kahlilkahlil9172 7 місяців тому

    How to store this configuration for real production spring boot ? I don't think I want to put my username and password in application.yml which will be git-ed.

    • @ENOCHPHAN
      @ENOCHPHAN 5 місяців тому

      You can put it on environment variable, and get value of it

  • @marouaneultra4968
    @marouaneultra4968 2 роки тому

    Darija plzzzzz ola arabic

    • @BoualiAli
      @BoualiAli  2 роки тому

      Sorry bro
      Most of my followers speak english

  • @abderrahmenhelaoui6511
    @abderrahmenhelaoui6511 2 роки тому +1

    Failed to execute CommandLineRunner Caused by: org.springframework.data.mongodb.UncategorizedMongoDbException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='helaoui', source='admin', password=, mechanismProperties=}; nested exception is com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='helaoui', source='admin', password=, mechanismProperties=}

    • @abderrahmenhelaoui6511
      @abderrahmenhelaoui6511 2 роки тому

      would you like to help me to fix the issue ?

    • @BoualiAli
      @BoualiAli  2 роки тому

      in which part?

    • @abderrahmenhelaoui6511
      @abderrahmenhelaoui6511 2 роки тому

      @@BoualiAli at time 1:06:48, save the product part

    • @abderrahmenhelaoui6511
      @abderrahmenhelaoui6511 2 роки тому

      this is what i wrote in docker-compose.yml:
      services:
      mongodb:
      image: mongo
      container_name: mongo_db
      ports:
      - 27017:27017
      volumes:
      - mongo:/data
      environment:
      - MONGO_INITDB_ROOT_USERNAME=helaoui
      - MONGO_INITDB_ROOT_PASSWORD=helaoui
      mongo-express:
      image: mongo-express
      container_name: mongo_express
      ports:
      - 8081:8081
      environment:
      - ME_CONFIG_MONGODB_ADMINUSERNAME=helaoui
      - ME_CONFIG_MONGODB_ADMINPASSWORD=helaoui
      - ME_CONFIG_MONGODB_SERVER=mongodb
      volumes:
      mongo: {}
      and this what i wrote in application.yml:
      spring:
      data:
      mongodb:
      username: helaoui
      password: helaoui
      host: localhost
      port: 27017
      database: helaouicoding
      when i omit the two lines from application.yml
      username: helaoui
      password: helaoui
      it works fine but i can't see the changes in mongo express

    • @BoualiAli
      @BoualiAli  2 роки тому

      @@abderrahmenhelaoui6511 there is a line missing.
      Check the source code on my github and you will figure it out