Build a CRUD Rest API in Java using Spring boot, Hibernate, Postgres, Docker and Docker Compose

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ม.ค. 2025

ความคิดเห็น • 79

  • @francescociulla
    @francescociulla  ปีที่แล้ว +3

    Find Francesco: francescociulla.com
    0:00:00 Intro, Requisites, architecture: Spring Boot, Hibernate, Postgres, Docker, Docker Compose
    0:04:48 Java Spring Boot app initialization. A first test with an ERROR.
    0:11:15 Postgres container in docker-compose.yml, TablePlus, applicationproperties, Error fixed.
    0:22:00 Java App: USer.java, UserRepository.java, UserController.java. Test
    0:43:10 Dockerfile, docker-compose.yml
    0:57:00 Test with Postman

  • @marcelomachado7168
    @marcelomachado7168 ปีที่แล้ว +4

    Thank you Francesco, you saved my life, I've been with this issue for a long days, and any tutorials helped me, because they don't explained about this issue.
    PS: If anyone have a problem when type "docker compose up" and occurs an issue about your DB password its wrong, just close de POSTGRES, only works if the POSTGRES its closed.

    • @francescociulla
      @francescociulla  ปีที่แล้ว

      you are welcome! your comment has been featured here twitter.com/FrancescoCiull4/status/1747812657782984753

  • @lodimateus
    @lodimateus ปีที่แล้ว +3

    I got stuck in mvn building a doing tests with my localhost variables, I last about one day, trying to manage how get out of this situation, Francesco you came as an angel to me, THANK YOU!!!!!!!!!!! I think i was crazy because of this ahahahahhaa

  • @danielkacou5891
    @danielkacou5891 5 หลายเดือนก่อน +2

    Thanks a lot for the great Docker tutorial. Greetings from Ivory Coast. 🔥

    • @francescociulla
      @francescociulla  5 หลายเดือนก่อน

      thank you. your comment ahs been featured here: x.com/FrancescoCiull4/status/1819990331992985642

  • @kirtanbornvita194
    @kirtanbornvita194 7 หลายเดือนก่อน +2

    Finally started the video and it going very well really appreciate the work 🔥🔥🔥🔥

  • @amanpatell
    @amanpatell 2 หลายเดือนก่อน +1

    Smooth as butter. Thanks 💓

    • @francescociulla
      @francescociulla  2 หลายเดือนก่อน

      you are welcome!

    • @amanpatell
      @amanpatell 2 หลายเดือนก่อน

      @@francescociulla would you consider making spring boot tutorial? Loved your explanation.

  • @AnkitAgarwal-u1h
    @AnkitAgarwal-u1h ปีที่แล้ว +1

    Thanks @Francesco. Very well explained. I usually prepare Spring Boot Applications using Eclipse but amazed by the cool features of Visual Studio. Also great to see containerization of java application. Although, i didn't get complete hold of docker compose due to have beginner knowledge of docker

  • @TheAthanik
    @TheAthanik ปีที่แล้ว +1

    It would be recommended to use constructor injection when using spring. An easy way to do that would be to declare the UserRepository field as private final and then use it in the constructor of the controller as an argument like this:
    ...
    private final UserRepository repository;
    public UserController(UserRepository repository) {
    this.repository = repository;
    }
    ...
    And you don't need to use the @Autowired annotation. It is implied. Also, the preferred way to do dependency injection, is considered best practice.
    Really like your style of the video. Came here mainly for the docker stuff :D
    Thanks for taking the time to do this tutorial.

    • @francescociulla
      @francescociulla  ปีที่แล้ว +3

      thanks for the update. the thing is that I didn't find a decent video explaining this stuff, and i was more focused on the docker part. I would def come back at this comment in case I'd do more stuff with Spring boot, that is actualy the first tech I used to create an API

  • @nkantartzopoulos
    @nkantartzopoulos 7 หลายเดือนก่อน +2

    If I could like this video 16 times I would do so.

    • @francescociulla
      @francescociulla  7 หลายเดือนก่อน

      Thank you, appreciated!!

  • @jaybamroliya6443
    @jaybamroliya6443 ปีที่แล้ว +2

    Hey @Francesco Ciulla , You are doing amazing work , I am Java Developer and also working in spring boot so any need for community so I am always ready.

  • @0x8strom
    @0x8strom ปีที่แล้ว +1

    awesome video!
    for more spring magic you can check out the version 3.1.0-RC2 which automatically scans for a docker-compose file in the project directory and spins/stops up the containers. i really found it useful.
    hello francesco!

    • @francescociulla
      @francescociulla  ปีที่แล้ว +1

      will take a look, thanks!

    • @0x8strom
      @0x8strom ปีที่แล้ว

      @@francescociulla i was hoping to get some pointers on applying for java/spring backend roles. what kind of portfolio projects do you think would be great to showcase?

  • @KoniKone1950
    @KoniKone1950 ปีที่แล้ว +1

    i have a question... whenever i run the command at 15:20 there's an exception... "Additional property container name is not allowed"... beats me what i'm doing wrong

    • @KoniKone1950
      @KoniKone1950 ปีที่แล้ว +1

      nvm... i wrote "container name" and it should be "container_name"... always double check for typos

    • @francescociulla
      @francescociulla  ปีที่แล้ว

      great you fixed it!

  • @preciousmutungi9614
    @preciousmutungi9614 7 หลายเดือนก่อน +1

    thank you. this helped alot!

  • @ossurf
    @ossurf ปีที่แล้ว +1

    Francesco TOP!!!!!!

  • @jakub.686
    @jakub.686 11 หลายเดือนก่อน +1

    good job, thank you!

  • @sillycoda1084
    @sillycoda1084 ปีที่แล้ว +1

    Thank you so much for your hard work! I am following through your guide now :) One question - what extension are you using in VSCode to have all the autocompletions being done for you? Especially in the properties file, see @ 18:00 timestamp.. Thank you and keep up the great work! Subb'ed :)

    • @francescociulla
      @francescociulla  ปีที่แล้ว

      it's GitHub Copilot. RXJs fan here, I am friend wkrh Ben Lash!

  • @KevinWebStudio
    @KevinWebStudio 11 หลายเดือนก่อน +1

    thanks a lot

  • @brettrucks7983
    @brettrucks7983 ปีที่แล้ว +1

    im getting this error " Error creating bean with name 'entityManagerFactory' defined in class path resource" when i run docker compose up

    • @brettrucks7983
      @brettrucks7983 ปีที่แล้ว

      its actually happening when i pull your down to so I must have something configured wrong on my vm

    • @francescociulla
      @francescociulla  ปีที่แล้ว

      it might be related to the db configuration, did you lone the project and trie to run it?

  • @tobee1377
    @tobee1377 5 หลายเดือนก่อน +1

    This is a good tutorial. Thanks!!! I am completely new to Docker and would like to know one thing. If I am using postgresql in one app, I am not able to use it another app. Error is showing port 5432 already in use. Isn't there any way where I can create one dedicated service for postgresql db and use it in multiple apps?

    • @francescociulla
      @francescociulla  5 หลายเดือนก่อน

      thank you. Yes, you can create a single PostgreSQL container and connect multiple apps to it. Just run the PostgreSQL container once, expose port 5432, and then configure your apps to connect to this shared database container instead of each running their own. let me know if that works

  • @techadventures6645
    @techadventures6645 ปีที่แล้ว +1

    Hi, I liked the tutorial but I find it bit long to launch the server.
    Do I have to type everytime I wanna launch server : mvn clean install -DskipTests + docker compose build + docker compose up ?
    Are there no way to make it faster with maven ?

    • @francescociulla
      @francescociulla  ปีที่แล้ว

      I agree it's a slow process but it has its pros and cons. you can try to use a mvn image from docker hub and build inside the mvn

    • @AN-tk5os
      @AN-tk5os ปีที่แล้ว

      ​@@francescociulla sir is it possible to do multi stage build and then run mvn and others at same time using dockerfile

  • @supasweetato1538
    @supasweetato1538 ปีที่แล้ว +1

    Hi ! Really enjoyed your tutorial. Can you please tell me what is your plugin with expanded autocomplete code ?

  • @davetelekom443
    @davetelekom443 8 หลายเดือนก่อน +1

    I am using the last Maven version, and do not build, I get errors.

    • @francescociulla
      @francescociulla  8 หลายเดือนก่อน

      what error?

    • @davetelekom443
      @davetelekom443 8 หลายเดือนก่อน +1

      @@francescociulla I fixed. Some jdbc message when trying. I am using mysql so I added the dependency in the pom file and changed the dialect in the app.propierties file and now it works

    • @francescociulla
      @francescociulla  8 หลายเดือนก่อน

      @@davetelekom443 ah you were using a differet db, yes of course you need to add the dependency. Well done!

  • @-maxxxeffect
    @-maxxxeffect 10 หลายเดือนก่อน +1

    Hey, great video!
    Sorry, just don't understand how does it work without UserService layer. In fact you didn't write findAll, fundByID methods. Why is there not compilation error? Why is the project launched succesfully.
    BTW I'm using gradle instead maven now

    • @francescociulla
      @francescociulla  9 หลายเดือนก่อน

      Thanks Max. it depends on the class you use in the Spring Data. the one I use automatically uses a service, that as intended to make the video easier. yes it should work well with Gradle, too (honestly I prefer that, but I wanted to make a video understandable by as many people as possible, that's why I used Maven)

    • @-maxxxeffect
      @-maxxxeffect 9 หลายเดือนก่อน +1

      @@francescociulla thank you!

    • @francescociulla
      @francescociulla  9 หลายเดือนก่อน

      @@-maxxxeffect you are welcome, glad it helped!

  • @andrei3720
    @andrei3720 ปีที่แล้ว +1

    I followed your tutorial step by step. Which is very good by the way. The problem is that I get an error: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP
    connections. I got this error doing your tutorial and I also got it on an older project that I made in the past. The applications both work without docker. But whenever I do something with docker I get this error. I dont know what to do. Would reinstalling postgres maybe fix it? But I have many databases there and I dont want to lose them

    • @francescociulla
      @francescociulla  ปีที่แล้ว +1

      do you already have something running on port 5432? which are the logs?

    • @andrei3720
      @andrei3720 ปีที่แล้ว +1

      @@francescociulla I shouldnt have. Only the postgres database is set on that port. I dont know the reason why I have this error. Maybe the only thing I can try is to reinstall postgres and clean everyhting. But I have this error happeneing not only on the project from this video but also on one of my older projects that I made in Spring

    • @francescociulla
      @francescociulla  ปีที่แล้ว

      @@andrei3720 you don't have to install postgres. it runs in a container

    • @andrei3720
      @andrei3720 ปีที่แล้ว

      @@francescociulla Then I have no idea what to do. The app runs good on the browser in localhost, but I cant make it compile and run with Docker

    • @mohammaddidehbanmehr7736
      @mohammaddidehbanmehr7736 ปีที่แล้ว

      @@andrei3720 might wroth a shot to try this if you haven't already:
      "sudo lsof -i:5432" then get the process id and do "sudo kill -9 "

  • @neb2777
    @neb2777 ปีที่แล้ว +1

    How do I connect a react frontend to this

    • @francescociulla
      @francescociulla  ปีที่แล้ว

      I am working on a video about this, stay tuned. you cna check this th-cam.com/video/Gf9RkaHnsR8/w-d-xo.html

    • @kameronwelch7503
      @kameronwelch7503 8 หลายเดือนก่อน

      @@francescociulla Hey Frances, Thanks for the great video. Are you still planning on creating a video on how to connect a react frontend to this? It would be very much appreciated.

  • @serychristianrenaud
    @serychristianrenaud ปีที่แล้ว +1

    thank

  • @yagizhan6342
    @yagizhan6342 6 หลายเดือนก่อน +1

    When ı post my variables passing as null

    • @francescociulla
      @francescociulla  6 หลายเดือนก่อน

      what do you mean?

    • @yagizhan6342
      @yagizhan6342 6 หลายเดือนก่อน +1

      @@francescociulla thanks I solved the problem ❤️

    • @francescociulla
      @francescociulla  6 หลายเดือนก่อน

      @@yagizhan6342 great, well done!

  • @bilalshaikh6603
    @bilalshaikh6603 ปีที่แล้ว +1

    Please share some resources to learn Java backend development.

    • @francescociulla
      @francescociulla  ปีที่แล้ว

      haven't read anything ina while, so I don'tknow

  • @shainkyjain3309
    @shainkyjain3309 7 หลายเดือนก่อน +1

    FATAL: password authentication failed for user "postgres"

    • @francescociulla
      @francescociulla  7 หลายเดือนก่อน

      the error seems clear, are you tunning another postgres instance, by chance? use your password

    • @shainkyjain3309
      @shainkyjain3309 7 หลายเดือนก่อน

      @@francescociulla who knows whats happen? i tried mySql and it works

    • @francescociulla
      @francescociulla  7 หลายเดือนก่อน

      @@shainkyjain3309 it might be the version of postgres or another postgres instance up and running. You can check the environment variables in the postgres container to read the value of the password

  • @pranavgor7278
    @pranavgor7278 2 หลายเดือนก่อน +2

    meanwhile me suing the eclipse and spring tool suite ☠

    • @francescociulla
      @francescociulla  หลายเดือนก่อน +1

      lol why?

    • @pranavgor7278
      @pranavgor7278 หลายเดือนก่อน

      @@francescociulla cause i am used