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

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome everyone in this video we will build a crab rest API in Java using spring boot hibernate postgres as a database Docker and Docker compose will use a different set of Technologies and we will go step by step in this tutorial there are also a couple of errors that I'll try to fix in the in this process so I hope that you I can fix some problems that you might have if you want to code in Java springboard and Docker but first of all let me tell you which are the requisites so the requisites are Docker installed and upper running on the machine here the Empire the app Docker at the bottom if I do docker Docker just Docker I have something so Docker is installed I have Java installed here on the machine so Docker Java and any ID okay I'll also tell you which are the extensions that you might want to install if you want to call the MBS code which is a kind of challenging let's say usually people who code in Java they use a different ID not vs code for different reasons so first of all let's check if my computer is uh is clean my PC is clean so I'm here in the terminal and I can do Docker ps-a this command shows us all the running and not running containers on our machine and I don't have any container up and running we can show also the images and it's empty so we don't have any container and an image perfect at the end of this tutorial we'll have something here now the architecture the architecture is kind of simple we will say we will create the five endpoints to cover four crowd API karate stands for create read update and delete and it's basically the default um functionalities that we want when we connected to a DB here you see the main application which will be a Java application using springboard 3.0 hibernate will be our orm which basically will help us to handle insert and queries with DB without typing SQL queries all of these these will become a Docker image and then a Docker container we will run the postgres instance in a container here and we will link them using Docker compose these two containers will run on a network on the same network the first time we can also show you something as a test tools you can use whatever you want I'll use a postman to test the apis and table plus to test if the database is working or not now follow along because these will be a little bit diff more different slightly different rather than my usual videos because usually I create the application and then I connected in this case we'll do something a bit different so if we want to code in Visual Studio code with Java we need to install some extensions now there are many there are some extensions that you might want to to install but I think that for what we need today we need two set of extensions the first one is the Java second it's called extension pack for Java is this one that is basically more other other extensions the other one that I'm going to install that I already have installed it is this one spring initializer with a sort of typos but it's uh this is the real name Java Java support okay so these are the two main extension or extensions back I should say so after we do this then if we have these two extensions installed when we create when we open if we open Visual Studio is a bit tricky well if we open Visual Studio code without a folder we will see this button can you see this this create Java project and this will be fun and a bit different than what we usually do so if we click here ER you will have a sort of prompt here something like that so then we can I think we can go here and we can select the spring but so we want to create a Java spring boot application okay then we need to decide the the Builder and the the package manager in this case I'll use maven the version of spring boot it will be 3.0.4 every 3.x should work then we should we can Define the language so we can use Java kotlin or groovy we're going with Java in this case and then we should Define the the package in this case I leave the default one com dot example you can use uh different ones of course for production ready Java code here we are not writing a production ready Java code so if we did enter there is the ID of the artifact which is a sort of the uh the name of the project in this case I will call this live so I'm sure that if I see live I'm talking about this project and not some tests that I made of course before I tried to came prepared for this one so now something string I don't know here okay the packaging type we can go with jar or War we can go with jar the Java version in this case it will be Java 17. and then we need to specify the dependencies now I you see can you see here I have a last used because I already made a couple of tries but if you if you if you have never done this before you should have an empty last used and there are three dependencies that you should installed so I'll try I'll type with you so it's a it's easier to follow so spring web which is basically to handle HTTP requests then spring data which is basically to handle persistence API with with hibernate and also this is also for different types of DBS and then the postgres ql driver okay stick with me because we are about to do something a bit strange very soon I'm trying to follow along so okay so select the three dependencies okay so this is a bit strange it opens up my folder Big Y because that now I want I can create a sort of boilerplate a soft code to start coding this application so we select the folder this will already create a folder so we don't need to specify another folder so for example in my case it will be C dot Works uh the lecture sorry C the slash workspace the folder let's see okay and now so basically we use the visual studio code as a prompt command we can also use something called the spring initializer on the web but here we are doing this inside your studio code which I think it's uh it's better now okay the notification disappeared okay now we can open this project and now this should look a bit more familiar okay so we so we have this initial Java project so if you are familiar with Java uh probably you know what we are talking about here let me go fast of what we see here maybe you can do a little bit bigger okay and a moment okay just a moment so we have a pom.xml file which is basically two handle dependencies it should be okay so I should not touch this is a sort of package.json if you could in JavaScript then we have.md file which is playing some stuff a Target folder which is basically to create the build a git ignore to ignore some some parts in this folder but the most interesting part is this one we have this main folder and inside that we have a Java folder and the resources folder so by encoding nothing we already have a lot of code okay um um do we have this application dot properties file which is a sort of Dot and the file so this is the file that we can use in Spring boot to in Java in springbot specifically to handle environment variables we need to handle them environment variables but let's go to the harder part because now we have this spring boot application and we would like to test it so I ex so since I have installed the extensions I would expect that if I click here play run Java this should work so let's see let's type this up run Java command and let's see what happens we have an error I've been working I've been crying about this error for days the first time because oh my God I created some default project I click Like play I would expect that this will run so the the thing is here is that since I defined a connection with the DB when I try to run my Java application basically the job application is expecting this connection with the postgres DB soul to solve this error we should have a running postgres instance on our machine so in this case we have two choices one we install postgres from zero on our machine or we run postgres in a container you probably know which of which one of the solutions we are about to uh to follow so so let's try this let's try at least to solve this this error so we can actually start coding without this this error so um okay so in this case let me see [Music] so let's create the um postgres container so let's create a file called Docker Dash compose Dot yml okay and we have seen this already multiple times but let's do this again the difference here is that we are writing Docker compose since the beginning this is the only difference so a Docker compost file is a file to Define to Define Services services are basically containers okay so the service that we want to Define here is the so we have Services of course and we have we will let's start with the with the service of the DB and we'll also test this with the table plus so Java underscore DB I call it Java DB because this is a Java project it's not really a Java Java container there's nothing to do with Java so container name we can define a container name when we Define a service we call it a Java we can call it Java DB then we need we can define an image that we want to use it is not my SQL GitHub copilot is failing us today postgres 12 for now then we can Define the port that we want to listen to this is basically the same postgres container that I've been doing already four times the main reason is that at some point we'll create a set of different Services connected to the same DB and that that is where things will become interesting now let's define the environment variables for postgres I kindly remind you that this is RR and key value pairs that have been defined by the postgres team so I can change this key I can only change the value here user password NDB I usually leave a postgres lately because probably in the in some final videos I'll use something different but let's go with the easiest possible part volumes are a way to have persistency with volumes with containers volumes so let's Define volumes again we are defining the postgres container for okay the postgres container to basically don't make our app to crush that's the idea so we defined the postgres container and now let's run the instance so if I didn't made any typo let's do Docker compose which stands for detached and then Java underscore DB hey we have done this multiple times and as you can see here I removed all the images on my PC so when I do Docker compose app with this postgres based image it pulls the image from the car habitat loads the image we might say on our machine usually this takes a while and now we will test these with table Plus usually before testing the table plus I see if at least we have the container up and running the container is up and running so let's go with table Plus or any literally any tool you want in this case I use table plus I click on the on the plus here pun intended and we can we make a postgresql connection type as a host I type localhost as a port 5432 as a user postgres and usually I copy paste this because I don't want to make typos so localhost postgres postgres postgres these three values are basically the values that we have here user username password and DB stands for database of course so let's try to make a connection connection is okay this is already a good sign and if we try to connect to this DB we have an empty DB this is perfect this is correct so in this case it's a bit different what what I usually do we already have the container up and running now we need to connect this is this part is very important we need to connect the Java Springer boot application to this DB otherwise it's gonna crash every time we type run so how can we do that we can go on the resources file and then we can Define some properties here so I hope a GitHub couple will help me but basically we will have uh spring dot data source data source URL this is wrong URL let's see around see if we have it is okay okay jdbc it's not my sequel but it's a pause Gras qwell postgresql localhost and then this should be postgres because the password is also the name of the DB when we create a postgres instance it has a default DB called postgres not very creative but it work now and data source username password this might be Francesco my name the name of the user and then as a password post aggress and it is okay for this example now I want to do a couple of more I want to add a couple of more environment variables that might be useful in the future so we want the our entity our model that we will we will Define in our application to be automatically updated in the DB so we want to reflect the changes we made on make on the code in the DB for example we will create a model of the user we want to create a user table in the DB without any making any SQL queries this is usually one of my favorite ways to interact with and then we need to define the the dialect because I remember you that this sort of orms they can they works with different databases so we can have a postgres dialect and MySQL dialect in this case we are using of course the post postgresql dialect okay now by doing this when I click play now the application should run and to to test it we can do we can do a Hello World uh basically print here in the code so let's see if if these works or not let's try let me click clear things here let's remove this let's see as you can see now my application it started can you see here the hello world so this took me days to solve this issue because uh basically Java and spring boot they tell you okay we will create a default DB if you run a database but if you are defining your own dependencies like we did in this case a spring data jpa you know what you're doing so you should know that you should add these things in this application dot properties file so this is the first good step okay which solves a lot of bugs the things is that here we are not we have not dockerized our spring boot application yet if you check it well here we are connecting to postgresql localhost 5432 so basically our Java application is doing exactly the same of what is doing table plus but it's not creating and anything for now okay if you are the whoops expert probably you know what how this line should change when we will dockerize this job application we want to dockerize this Java application we don't want to create just a jar file but we want to create a Docker image and then the docker containing container based on this image okay but anyway this one is what is this was good nice now let's start creating our application so I'll try I'll code this uh from scratch let me stop this I think I can also done okay let's do this and this nice so how can we create a resource in Java so usually in this case what we can do is that we can create a new folder and this folder can be called for example user so the name of the resource that you want to access to now in this um in this folder one server in this folder we we will create three different files so let's start with the model so let's create a file called user dot Java I haven't written a Java class in a while so okay so I think that we can start by importing something for the princess persistency it's called This is basically the spring data GPA that we we already imported so persistence I think this is okay so let's uh nothing nice it's complaining because it's not being used now here in this class this will be like a Java class on steroids so this will have annotations in this class so first of all we want this to be an entity because we want this to be synchronized with the database this will make some magic will create the table for us we can also Define the table name we want in this case I want to create a table called users and now inside the Java class we can Define okay this looks good looks good but let's type it from uh let's type it together so um so this we want this to be a an ID for the when we create the user in ADB we want an incremental ID and then we can do a generated value generation type here usually I use Auto so this will and basically this will handle the incremental thing like we will create a user will it will assign ID one two three four five and so on okay nothing strange here let's see it's a normal stuff now we create a property with a column annotation the column annotation of course is the column in the DB I think there should be consistency between the name of the variable we use here and the column but we will also Define a different one usually I like that these these properties field is the same as the DB column okay and then so name and email okay let's let's start with the easy easy part now since we are in Java we need to define the getter getter and setters get theirs and Setters method let's see if I get some help I don't get any help so public long so the ID will be a longer which is basically an INT with with more more bytes so we have the the methods to to get an ID and one to set the ID we need a gathering Setter for the three popper properties so we have the getter for the for the name the setter for the name the getter for the for the mail and the sector for day email probably there is a a more agile method to do this you can use something called The Long book I think in Java but in this case let's go with simple stuff okay so it's uh it's done okay amazing now we need to handle the um all the the connections and all the the controllers and all the stuff so how can we do this uh we're using springboard to be honest here in springboot they made a very good job so I can use this I can create something called the user repository dot Java so I call I I create this this will be an interface called the user repository but uh basically this will and we will annotate this as a repository repository is basically a resource I don't know why they call this repository which is also clashes with the idea of repository in git but it has nothing to do with the GitHub repository it's basically a resource okay so user repository X stance so extends user reports public interface interface user repository extends jpa repository with the I user and a longer okay okay and these was everything we had to do for the user Repository [Music] um okay this should work okay so basically we created a repository which is missing a resource using a user user class you see here and the longer because we need the type of the primary key in the DB which in this case is this ID this ID is the primary key okay nice so this is an interface so this will let us to handle things in a way way um handful and a meaningful way now we need just one more Java file this file will be called user controller user controller dot Java okay nice so this user controller will contain all the logic in the logic for our application and so let's start typing this right now and then we will handle all the Imports here so first of all we can annotate this with something called the rest controller the rest controller as we say here is a convenience a notation that to annotate so basically this is to handle with less adhes the HTTP request we will have some hands very useful annotations inside our methods okay now this is we can use this annotation which is called request mapping and this is kinda intuitive I think because this will be sorry foreign [Music] what's going on here so when we will go to the slash API slash users mapping in the URL we will call different controllers different functions okay now to make to make this user controls to work we need to use something called dependency injection so we want to inject the user of repository so to do this we can go with this annotation called out wired and then we can import this private user Repository and we can import it okay no we already imported it but it's complaining because it doesn't use okay give us a moment nice now we can use a different annotations my favorite annotation is to use the different annotations based on the HTTP method so instead of using request mapping by explaining which will be the verb in The annotation itself we will have a get post put and delete these are will be the four verbs that we will use so we can use something called get mapping get mapping what is this don't need anything else here okay what is this so get mapping and then we can have a public list of user users list of type user and then we can get all the user okay Okay so I have to it's not importing it's not importing the Java list add this like that okay so now we don't take this okay so we so can you see here how this is very simple because uh here we are basically just to want to to get all the users okay very very easy I love because okay we made some effort to to to arrive in this file but to be honest the controller is very well done so we just have to do a DOT find all and we did this will abstract all the logic which is very cool get mapping so this is to get all the users but we also want to get a single user and then all all the missing we need to handle all the things so and here another thing that I really like about spring button at least I liked in the past so here so let's do another mapping here get mapping okay oh okay so this is very clear so the controller will be very clean compared to other Technologies because here you can see get mapping slash curly bracket brackets ID and then we have this method with a request param no this is not to respond but it's path variable path variable because we want this in the URL so we want this in the path okay usually I prefer to have this approach and then we can return the user now probably if we have time we'll also handle some errors but in here for now I'm happy with that so if you have ever worked with API this should be clear because here when we go for example to slash API slash users slash three we want the user number three with the name and email and probably the ID okay now we have three more crowd operations to go ayabi it's always a pleasure so let's do the post post nothing most mapping it means that we want to notice this we want to make some operation when we have a post request in this case of course we will create a new user so post mapping it doesn't have any sub button here so we can call this a public user create user and here we have this which is very useful the request body request body it means that we'll have the body in Json format for the user okay this is very cool and let's go with three more the put mapping put mapping okay usually the put is the most complicated one let's remove this because this is not what we need and here we can have ID so for the do remember the put request is to modify an existing user okay so let's see if I like it I think I like this one but let me explain what happened here so we have this method called update user and we have this slash ID as a path variable path variable so like we want to modify the user number three we go on we could do a put request on slash API slash users slash three but then when we do a put request we want to provide the body of the new user so we need to do as in a similar way as we do in the post request but so we need both a path variable and a request body then we create we get the existing user by finding the user by ID in the dbe we probably need to do some some handle error handling here but for now I'm happy with that because you are more focused on the connection between Docker the docker container for the Apple the docker container of the DB this is what we want to highlight in these tutorials but if we have some time we can also handle some errors here and now the last one it's the delete delete nothing so we want to delete a user when we have some error in this case I think we can try to do a try catch let's let's try so if okay so if we okay so in this case I want to return a string so in case the user has been deleted we will return a user deleted successfully otherwise we will return user not found okay so if the user if you want try to to delete the user number 10 but the user number 10 does not exist we should return an error because probably we were trying to delete the user that didn't exist it has some error logic I think that I made all the Java code in this live stream so but this is not enough okay we need to let's see what we need to do now so we did we created the user.java we created the user Repository okay request param we don't need it okay uh okay now I want to try something which is different from what I usually do when I do these uh tutorials so usually I create the app I dockerize the app and then I connected them with ADB with Java I want to use a different approach so I wanted to try to connect this Java application with the postgres container but before dockerizing the job application the tokenization will will be basically the jar jar file inside the inside uh an image which is also combinative so the person who will use that doesn't doesn't read the specific version of java we know that Java has different versions for different PCS so that's it so now let's try to handle this and probably we need to solve some errors every time I've done this I had some error so let's see okay it seems that it worked so API slash users the jar is basically the the build for Java let's try to get the users and we have an empty array this is very good now before dockerizing this Java application I want to show you something let's go back on table plus here and let's try to refresh and as you can see now here we have the table but this table has not been triggered by this get request the table now is appeared in the volume of the postgres container and we will keep using this even after we will dockerize the Java application how Problem by this in the model we defined the entity and the table name so basically when the Java application starts it checks if we have if it has an entity and table class Java class on steroids and in that case it already creates the table or it will change the structure of the table so this is very powerful we didn't type like create table if that doesn't exist users okay so it has been handled automatically and honestly I always like this approach nice okay we're done no not yet because now we want them I know I know Graham so okay so now stick with me because we have some weird stuff going on soon by the way thank you so much for watching this live stream it's my personal Revenge with Java but I still I still don't know if I'll make it but we are three four uh with fifty percent seventy percent there now I want to build this uh I want to build this Java app now check what happens if I type okay so to build so the equivalent on of npm run build for JavaScript node.js developers is miven clean package we need Maven on our machine in our requirements I think I forgot to say this so we need Maven so when we install Maven but it's very easy to install it we can do mbn so I need to update these 20 this is requirement so the command to create uh the the Java packages may even we have different ones but let's go with clean package and see what happens here are you ready no no music Marvin clean package I'm building this let's see ah it worked I don't know why ah wait wait wait okay no no okay it worked it worked because this is still the Java application okay no no okay so here it worked so we built the image the problem is that look here here we have the environment variables in the application.properties file but we would like to have this environment variables not at the application Level but on the configuration level so we need to do some stuff here so let's now finally dockerize this Java application and then I'll come back to this error so I was expecting an error and I didn't got an error so this is basically an error Okay so how can we create a Docker image a Docker image is a file on our system or somewhere else and then on top of that we'll run the container so usually it's not a must we need to create a file called Docker file we can also also use a different name and probably I'll use this in one of the upcoming live streams but if we have only one file it doesn't make sense so you don't use the default ones otherwise you can use the Java Docker file or something else in that case we need to specify the name of the docker file so now here we will handle just the final Java jar so open jdk I don't know what happened with the Java version 3D case to be honest I don't want to know jdk Alpine so I want to start with this and then we want to copy the name also let me find let me build this again so we want simply to copy the target file the jar file the compile file in the docker images so this is a different process of what I usually do usually I copy and build inside the image in this case I decided with this different approach now this is the name of the file so basically here what we do is simply copy this single file dot jar in the and and then we can use any name we want let's go with the app up this version so so basically we create we copy this jar file inside the docker image file system with a different name why is it complaining I don't know and then here we can use the entry point here entry point let's see if we have some help Java jar okay why is it complaining I know okay wait wait wait wait wait wait wait what is this like this Okay so so this is the the base image Java one this is cool because so you can run this in this instance without having Java installed on your machine then we will copy this target file okay and then we will basically run this jar file I use a different name here but it's okay now what we need to do is to define the services and on purpose I did I said in less than one hour but probably this will not be enough so Java but to be honest I want to take it easy because I want to really explain what's going on here so possibly I lost I lost my channel but I don't care I don't care so the name of this Java app will be usually I use the same name of the service here and then we need to define the image in this case the image will be 0.0 so this will be the version of our application it will be build dot so we want to build this okay then we want to Define the the ports 8080 is cool it's okay and then the environment variables now we need to define the environment variables and we want to break them at the docker level this part is very important because here we go on the resources do you do you remember that we had these ones here so we want to Define some environmental variables that we will inject inside the application when we will run it okay so database database and the score URL okay and we will use this one then the database username is possible this password is postgres and this is okay and I think that's it we just have to type depends on okay so probably we so you saw this already a couple of times if you have been following this series but basically we are defining here three environment variables database URL database username database password okay now let's spend two more minutes to understand this here in the application.properties I already had this so if I just Define them in the docker compose it doesn't make sense to tell the application please use what I'll pass you in as an environment variable already because Docker is a wrapper around spring boot we need to I think it's like that I think is this uh I need to check because I'm not sure yes okay so for the username we can use this we're using the key here okay then here we will use let's see here so instead of hard coding hit them here database password can you see okay so this is crucial here I defined localhost 5432 because the connection of a simple Java application it's like table plus they use a localhost okay instead when I can Define instead when we use docker remember this the containers communicate each other by the name of the container the name of the continuation no localhost but the name of the services so in this case here we will pass this as an environment variable so is dollar sign database URL okay so because here we are just passing the now let's say that I want to build the jar file locally then I want to upload the copy the jar file in a Docker image and then run this why should I need to want to do this because by doing this that the person will use this service they don't need the Java installed so this is the the only advantage now sounded I've been fighting for maybe weeks so everything is set so let's build the Java image again let's see what happens even clean package [Music] it's bum error I've been fighting with this error for days a weeks okay so long I I'll I'll avoid you I'll uh I will give you some some um some head ages the problem is that locally on my machine I Define some environment variables then I want to build this in this Java image the problem is that when I build the Java image maven listen tries to connect with the DB here on my machine so it gives an error on the build because Maven can't connect with the postgres instance on this machine which is a the craziest thing that I've ever heard about building cradle rest API so it seems something that it's um it's good for me but for me it's honestly it's not because I know what I'm doing I'm building a Java ajar file and then I'll make that service to handle with something else I don't want to Define how I connect to the container in the application I want to do this on the configuration level you get what I mean so so by just the changing these basically here maybe it doesn't know what happens here they say okay where do I get this environment variable you should not care it's not your business anyway how can we solve this issue because I still want to like to build the job so we have two choices either we build this in the Java in the docker image or we can do something more raw but it usually works so I can build this without test so now and clean package I never remember this Dash D skip this okay in this case it's legit let's see if it works because I always make a typo when I type this so just build the image you don't have to try to connect with ADB when you build the image Okay so now I built this image and this image is this one okay live zero zero one snapshot dot jar now it's not complaining because I say the skip test but now this is not should be no more a simple Java application but it's a dockerized Java application so now we can run this with the usual command we use to run this application which is of course Docker compose app and in this case we will run the spring boot application inside a Docker container and our job it will be done of course after the test them okay so let's do it no for that sorry before that we need to build the image so Docker compose build because we built the jar we built the jar but then we wanted to build the docker image all right let me let me check if we have any other images no we have just posted this so we have to do Docker compose build you will not see the docker compose build very often the tutorials because usually tutorials boom boom it builds the stuff it works if there for them it works build is not a necessary step if I do Docker compose up but here we have the same result because if the docker if I run Docker compose up and I don't have this image on my machine it will build my images so we are doing this for demo purposes doing Docker compost build so we will also going step by step so if we have a problem we can do the troubleshooting here I prefer this approach when I explain so Docker compose build once you understand you can just do Docker compose up here build them okay so we have an error here because it's trying to copy this file that is not finding why let's see what's the problem here let's uh take this Docker file okay okay live this should be it's not copying these not found interesting let's try again Bob and clean package so I want to copy these file ah because I think I need the I need the part Target here the path Target I need to copy the target this option so now Docker compose build let's see okay uh no there is a typo typo I will make it now I want to make it today so okay so we now copied this inside the docker image now we should be good to go so let's do let's try Docker compose app and then let's see what happens Docker compose okay hello world maybe it worked let's go so first of all let's check here foreign so we have here uh two Docker containers one is running on the port of 5432 and one on the port 8080. I think you can also use these is this do you prefer this one do you prefer this UI interface so we have this Java app let me make it bigger no I can make it bigger so this and this okay probably at some point I can also use some of these but okay number I like to prefer raw stuff now let's try to get the users again we are getting the user again here's again the difference now is that we are doing this with a containerized application and now of course we will test all the apis so Let's uh let's start adding someone so gram this is Grand mail .com so let's start start adding some people so we add the gram let's add the franchise question in the chart you can you can do it now branchesco mail.com one more Toby Toby Loba Tobin Solutions okay okay so we added the three uh let's try to get the users again okay and as you can see here we have the three users to make the get requests we can also show you I can also here go here so we can we have the three users here now to change an existing user here is a bit tricky we need also to we need to put for example let's change my name we can also Define these in this case this can be handled better but it's okay so this is fra this is for a mail so let's update the the user Nam user tool okay let's try to get a single user oh no [Music] no okay so we will get this one and this okay and with the slash okay okay and now let's try to delete the user number two by doing this on HTTP uh request with a delete verb here user delete a successfully if I try let's try to get them and we have just a user's ID one and three now as you can see if I try to delete the user that doesn't exist I should get an error no okay maybe we can try to solve this very fast because uh let's let's try Okay so the basic rad API operations they work now the in this case I think that we should handle this primary key better so it's basically creating another ID this is basically creating another another insert we can say so we should handle this in a better way [Music] by using the different increments so in the final version of this we will handle this better I just want to do this fast if I can do it of course in the user controller when there is a h no no no no okay this is the problem that here we should first find the user and then delete it okay and then I think that we need here user controller but uh fine by Eddie and then use a repository basically is this um let's see okay because basically in this case if it doesn't find the ID it should okay let's try again last test by the way this is already our success at least for my side so let's build this again so I need to build the jar again locally then I need and I should have the updated version I think let's see let's see let's see let's see let's see okay let's try to delete the energy that does not exist at the moment it's getting an error okay user find by ID if I try to get the users okay it's working if we try to delete the user that does not exist those are not found okay in this case okay so I fixed this little error because as we say the delete it fails silently instead I want to say the user is not found amazing
Info
Channel: Francesco Ciulla
Views: 7,262
Rating: undefined out of 5
Keywords: spring boot, docker compose, docker tutorial, java tutorial for beginners, java tutorial, java programming, spring boot docker, spring boot crud operation, spring boot crud app, crud api java, crud api java spring boot, crud api java tutorial, build crud api, spring data jpa, spring data jpa tutorial, hibernate tutorial, spring web, maven, java vscode, java vscode extensions, java vscode extension pack, java, java maven, rest api java, crud operation using rest api in java
Id: Nefd6qdpdSI
Channel Id: undefined
Length: 63min 44sec (3824 seconds)
Published: Sun Mar 12 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.