MongoDB + Spring Boot 3 | Crash Course

Sdílet
Vložit
  • čas přidán 5. 08. 2024
  • Buy me a coffee: ko-fi.com/boualiali #spring #learning #springboot #springtutorial #springsecurity #developpement #java #arraylist #linkedlist #springdatajpa #querybuilder #aliboucoding #alibou #validation #mongodb #springboot_3
    In this crash course, you will learn how to build high-performance web applications using Spring Boot 3.0 and MongoDB.
    We'll start by discussing the key concepts of Spring Boot, including the basics of dependency injection, configuration, and testing.
    Then, we'll dive into MongoDB and explore its powerful features for data modeling, querying, and indexing.
    Along the way, we'll also cover best practices for optimizing the performance of your Spring Boot and MongoDB applications.
    By the end of this course, you will have a solid understanding of how to use these technologies together to create powerful, scalable, and maintainable web applications.
    Don't Forget to
    ===========================================
    💯 Free courses here: aliboucoding.com
    💯 Subscribe to the youtube channel
    💯 Join our Discord Community - / discord
    💯 Join our Facebook Group - / 589612651142975
    💯 Join our Instagram: / alibou_coding
    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

Komentáře • 55

  • @BoualiAli
    @BoualiAli  Před rokem +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

  • @user-oc8mk9iy9f
    @user-oc8mk9iy9f Před 7 měsíci +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 Před 5 měsíci +1

    Thank you very much for this video!

  • @boolhak
    @boolhak Před rokem

    ​thank you so much, you are the best

  • @hazel-BKJ
    @hazel-BKJ Před 4 měsíci

    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.

  • @waeljadla9688
    @waeljadla9688 Před rokem

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

  • @amenajroud6551
    @amenajroud6551 Před rokem

    Thx a lot Ali

  • @mukhammadnajimov8440
    @mukhammadnajimov8440 Před 5 měsíci

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

  • @user-rp2uo9cv4c
    @user-rp2uo9cv4c Před rokem +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.

  • @loshithahasaral3273
    @loshithahasaral3273 Před rokem

    Thank you very much

  • @SameeraSenarathna
    @SameeraSenarathna Před 2 měsíci

    Thank you

  • @Andrey198923
    @Andrey198923 Před rokem

    good tutorial

  • @aminechatate8487
    @aminechatate8487 Před rokem

    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

  • @ziadghouzlani4220
    @ziadghouzlani4220 Před rokem

    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  Před rokem

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

  • @kahlilkahlil9172
    @kahlilkahlil9172 Před měsícem

    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.

  • @ArunKumar-tr7ql
    @ArunKumar-tr7ql Před rokem

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

    • @BoualiAli
      @BoualiAli  Před rokem +1

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

  • @KuldeepKumar-ki6cu
    @KuldeepKumar-ki6cu Před rokem

    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

  • @daoudasylla91
    @daoudasylla91 Před rokem

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

  • @wmjabeen
    @wmjabeen Před 5 měsíci

    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?

  • @user-kn6yf7fp7k
    @user-kn6yf7fp7k Před 8 měsíci

    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 Před 6 měsíci

      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.

  • @codertravel99
    @codertravel99 Před 3 měsíci

    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  Před 3 měsíci

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

  • @NomadicAlfa
    @NomadicAlfa Před rokem

    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  Před rokem

      You have bad credentials to acces your mongo

    • @NomadicAlfa
      @NomadicAlfa Před rokem

      @@BoualiAli how to solve this issue?

    • @BoualiAli
      @BoualiAli  Před rokem

      @@NomadicAlfa set the correct credentials

    • @cevaponomaryov9044
      @cevaponomaryov9044 Před rokem

      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" } ]
      }
      )

  • @marouaneultra4968
    @marouaneultra4968 Před rokem

    Darija plzzzzz ola arabic

    • @BoualiAli
      @BoualiAli  Před rokem

      Sorry bro
      Most of my followers speak english

  • @abderrahmenhelaoui6511

    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 Před rokem

      would you like to help me to fix the issue ?

    • @BoualiAli
      @BoualiAli  Před rokem

      in which part?

    • @abderrahmenhelaoui6511
      @abderrahmenhelaoui6511 Před rokem

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

    • @abderrahmenhelaoui6511
      @abderrahmenhelaoui6511 Před rokem

      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  Před rokem

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