Full Stack Web Developer in 2022: Java, Spring Boot, MySQL, Docker [Part 1] | Alexandru Rosu | Skillshare

Playback Speed

  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Full Stack Web Developer in 2022: Java, Spring Boot, MySQL, Docker [Part 1]

teacher avatar Alexandru Rosu, Technology matters

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

36 Lessons (2h 56m)
    • 1. Introduction

    • 2. REST Architecture Principles

    • 3. Install Java JDK

    • 4. Install Maven

    • 5. Install Spring Tool Suite IDE

    • 6. Install Postman

    • 7. Create Spring Boot project using Spring Initializer

    • 8. Add Spring Boot Starter Web Dependency to our project

    • 9. Create initial package structure

    • 10. Initial implementation for Find All Users API

    • 11. Create random list of users

    • 12. Use Postman to invoke Find All Users API

    • 13. Initial implementation for Find User By Id API

    • 14. Introduce ResponseEntity

    • 15. Implement Add User API

    • 16. Create Delete User API

    • 17. Implement Update User API

    • 18. Introduce Spring Data JPA and H2 Database

    • 19. Update User model class to an entity

    • 20. Improve Find All Users API

    • 21. Modify Add User API

    • 22. Adapt Delete User API

    • 23. Improve Find User By Id API

    • 24. Modify Update User API

    • 25. Create mechanism to store users on application startup and refactor UserService

    • 26. Introduce Spring Boot Starter Security

    • 27. Implement customizable basic security

    • 28. Add PasswordEncoder mechanism

    • 29. Add Username and password fields to our User model class

    • 30. Encode passwords for users created on application startup

    • 31. Encode passwords for user created on Add and Update APIs

    • 32. Introduce Pagination for Find All Users API

    • 33. Implement custom search for user based on criteria

    • 34. Migrate from H2 to MySQL Database

    • 35. Migrate application to Docker Environment

    • 36. Prepare the server for UI interaction

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

This is the first class of the two class series of building a fully functional Full Stack REST API based application.

By taking this class you will:

  • Get your hands dirty by building a fully functional Spring Boot RESTful Java Application that will manage users
  • Understand how to structure a Spring Boot Application in different modules
  • Learn to code by creating an application in a step-by-step manner
  • Get an introduction to Spring Data JPA
  • Analyse default Spring Security concepts
  • Implement custom Spring Security authentication mechanism
  • Be confident that you learned the basics of building an application with one of the most popular frameworks on the market (Spring Boot)

Are there any course requirements or prerequisites?Ā Yes, just a few

  • Basic understanding of Java, Maven and Spring Framework
  • Willing to build a step by step application from scratch

Meet Your Teacher

Teacher Profile Image

Alexandru Rosu

Technology matters



My name is Alex and I am happy to join skillshare as an teacher.

I have a bachelor degree in Computer Science and a Master Degree in Multi modal distributed virtual environments.

With a strong passion for programming, I enjoy finding solutions to various IT related problems.

My favorite programming language? I can tell you that it's Java, but I have also worked with other languages such as NodeJS, Angular, Typescript, Python, etc in my previous 10 years of experience.

Will be happy to share my knowledge and create great content for everybody who wants to join my classes.

Let's build awesome things together :)

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.


1. Introduction: Hello guys, and welcome to the first part of the class series, where we will build together onComplete full-stack erased API, web-based application. Under the following videos, will create a springboard based backend server that will handle the process of managing users. You will gather knowledge of working with technologies such as Java, springboard, spring Security, spring data, JP8, and many more. In terms of storing data, we'll first start with an in-memory database called H2 and migrate to the well-known MySQL relational database. There are many things that I want to show you. So if you are engaged in this class, let's get started. 2. REST Architecture Principles: before diving in and start to implement coat that would correspond for STP I. We should have a quick overview off the main principles behind caressed http Status cold and so on. So what is a Web service? As a simple definition, this can be represented as a service component made available to users over the Internet. The multitude off protocols and standards available created since the end of the last century in the Internet fear have made it possible to communicate between applications on long distance systems with Internet access. Classic examples of Web services exposed on the Internet are fighting out the quarters stock price off a particle or stock, or finding out the weather conditions in a certain part off the world. What defines the rest are hit picture. It is an architectural style that defines a set off recommendations for designing applications that use the hypertext transfer protocol for data transmission. The reporters transfer protocol http represents is the foundation off the World Wide Web and can be seen as a protocol used for distributed collaborative hyper media information systems. In the following, we will analyze the main components that underlined the writing off rest based Web services . Those are http methods and steak Those coats Standard coat returned by the server based on a specific client request http Methods under arrest. Architecture http defines a set off request methods to indicate the desire action Toby performed for a particulary source. Although they can also be knowns, these methods off requests are sometimes referred to us. Http words The get method is used to withdraw data from a resource. The post method is used to create the resource. The put method is used toe update a resource. The deal it method can be used to delete a specific resource. The head method withdraws meta data from the server and the options well, we drove all possible words methods exposed by a resource. Http Status codes Status codes are issued by the server in response to a client request to the server. We will now present the main list off status codes. One x x information 100 stands for continue and was designed to send input toe. The Server two expects success 200 OK. The request was executed successfully and for 21 created, the request was fulfilled, resulting in the creation off the new result free X x or direction 301 Permanently mortified or moved. The request has been assigned when you and a permanent war I and subsequent requests should use one off the return your eyes for resources. Four. Expects client er 400. Wrong request. The request could not be understood. Perceived by the server. Do toe wrong or incomplete syntax for a one or notarized. The application requires user authentication for over a forbidden. The server understood that the request but refuses to fulfill it. User authorization doesn't have permission. Talks is the resource Final four not found. The server did not find anything matching the your I request. Five. X x server Error. 500 Internal server error. The server encounter on unexpected condition first incrementally applies five mandatory constraints and the optional one on the elements that make up the architecture client server. Separating the aspects off the user interface from the data storage stateless. Keeping session details strictly to the client does freeing the server from the burden off session management to bring scalability, security and visibility. The disadvantage is that each request will have to contain enough information. Toby Ableto proceed correctly. Cash the data that makes up our response must be labeled as cash usable or known, cash usable uniform interfaces between components. It simplifies nd couples the architecture along each party to evolve independently. Layer system the component can see and interact only with the layers in its immediate vicinity. For example, customers cannot assume that they are interacting directly with the data source because they can communicate with a cash level optional on demand code. Servers can temporarily extend or customize a client's functionality by transferring executable code, for example, compile components such as Java applets or client scripts such as JavaScript. 3. Install Java JDK: let's start by configuring our environment. So the first step is to download Install Java gvk one that date so we can navigate toe our browser and type in download Oracle J D K. We can say look the first course link and were directed toe oracle dot com Scroll down a bit. You can see that we'll choose J d k worsen eight. So between Windows 64 86 version, I'm Oh, no Windows environment with the 64 bit. So our choose this version, I don't know the gvk you will be redirected toe oracle type in your user name and the yes sort. So this is an oracle account that you should have now the genetic aids don't loading. You should open off, then the find it in the folder. Okay, so you can double, click and or just follow the steps to install it. Once you finish this process, the J T. K will be installed under sea folder. I'll quickly show you this. So see, program files java, and you can see it here. Now you need toe copy this path and city pondered the environment variables or your windows environment. So on the path variable. You can edit it and right at the end, based on content here. Okay. Looks good. And now you can taste that Gervais properly configured double minus version. And you can see that job I set up. 4. Install Maven: The next step is to download and install Oh, May 1 so we can navigate toe our browser typing download. Maybe one opened the first the link Scroll down a bit and search for the maven Corresponding zip. They should be the one. Version 36 free a way for this to be downloaded. Now we need to extract its content. So we'll go with extract here. Just a few seconds for the wants to be properly extracted. And we can copy this. Actually, let's cut this folder and move it toe a new location, maybe under tools. You can see that I have this version set up already. So we need to enter under being folder and co. P once again this path since we need to set it under environment variables. So advanced system settings pacer for pat and edit this variable and right at the end. We need to copy paste, actually based that the that path okay. And we can verify if May 1 is properly configured and the n minus version you can see that may 1 is properly configured on our environment also has Java behind the scenes to properly communicate with it 5. Install Spring Tool Suite IDE: we should move forward and the configure the Sprinkles with i d. So let's type, you know, Donald Sprint or sweep. We should select the four Stop shown we are under spring that i O Toole's and scroll down a search for the window. 64 bit version. We can keep this. So jar file showing folder and double click on it. And the behind the scenes a new folder will be created. Okay, let's see. Move this folder toe a preferred in the location. So I moved the standard D. Okay. And over here, we can exit. Quit the Sprinkles. Sweet for corresponding file. Toe opened. I d Let's Eric the A folder for our new project. Okay, wait for this to load. Great sold ideas open. But to be honest, I'm not quite happy with this white screen. I will choose a specific template so we can go with the eclipse marketplace and search here for wait a few seconds for this to load and we can search for dark esteem. Okay, so we need to install this thesis team off here and accept the terms on the license every month and click on finish bottom will be prompt to restart our I d for this team toe be taken into effect Starting software okay? Or to stop now. So now I'm restarting the i d. Click on next and select the darker steam before it is to load. Okay, so this Ah, this is how Sprinkle sweet looks. 6. Install Postman: the final prerequisite for our environment Set up process is to install Postman so we can type in the long postman. No, no postman app. And over here we can choose between 32 64 bit. I'm on a windows environment with 64 bit So I choose the second option. Okay, we can open now The postman executable so that the we will install the postman pap on our environment will use this up mostly for invoking or arrest Ap eyes So installing postman now the loader We should go Just keep us a few seconds for for post mental be properly installed and configured And now postman is ready to be used 7. Create Spring Boot project using Spring Initializer: Let's start by creating the initial structure for the spring boot application that search for spring boot initialize er on Google Chrome or any browser start spring that I owe and we can see the graphical user interface for setting up the spring Project can choose between Project May Burn the language Java Springwood 2 to 5 Project meta data or go with Come artifact There more for the name I will choose crowd application using spring boat. Same for the description. Let's remove the package name and let just calm packaging jar. And for job version, I will choose Java eight and no dependence is yet since they will be added later directly into our project. Let's extract content and removed the zip. I will cut this, uh, folder and movie Tonder the project. Okay, Now we need to open our spring boot tools. I d the Spring Tool Suite four. Okay, I have ah imported. I choose the file in the one thing important the maven project from the Project demo and now you can see that the demo project has appeared. It also took the spring boot configuration. I just want to rename this class toe something more simpler, such as main. Okay, Okay, does great. And we have the main class that is annotated with spring with application. 8. Add Spring Boot Starter Web Dependency to our project: Let's add the spin boots starter Web dependency under our project. So I opened bone file. We can see that we have the later spring version 2 to 5. Release next, though this we can see that we have Ah, springboard starter dependency. And also springboard started test. And we also need the stuck the work dependency. So I opened chrome chrome browser, That's it. And search for springboard starter dependency. We should wait for this to load and navigated toe Springwood reference documentation. And over here we should search for spring boot Starter Web. I found the dependency over here. Let me highlight it. Yeah, sorry for this. Let me get back to it once again and will copy paste this dependency and add it under the project Control Shift F on windows to format goat and just start the application Once again , you can see that one's disciplined since he has been added, um, the application has started. Also, there is an embedded Tomcat Web server that runs 1 80 80 I navigated to local host 80 80 and by default, we see this white label error page 9. Create initial package structure: Under this video, let's create together the initial project package structure, so navigate to the Project folder under Spring Bolt I D. And escape the new package. Let's call it Comb that controller that will keep our main application controller. Also another package called Comb that service where the Business Logic were decide. And those So Let's Kato, another package called Com that model where we'll keep our user model class. Lochte's open are conduct model package and create the new class called User. Under this close, I would like to set up some specific user properties such as first name, last name, age and country. So I created private string first name, private string, last name, private integer age, and let's also set up the private string country. Next to this, I also want toe generate or constructor, a simple constructor, nor argument constructor. Let's also generates, um, get her sense setters for our properties are selected or the properties from this model class after the main constructor, our creator not on additional constructor. We told the fields from our class, so I selected all of them. And let's create also the I think hash coding equals metals That's great they been generated. And finally we'll need toe. Add a two string method. This was also generated. So we have to string equals hash code. Get on setters. Constructor using fields in the North German constructor. 10. Initial implementation for Find All Users API: let's create together the basic implementation fourth or final users a p I. So let's create an interface from Com that service package and let's call it user service. Okay, under user service, I would like to set up a new method called Final. Ah, that's great. Let's actually return a list off users since we need to return multiple users. Okay, now we need to import the You have a list and also the user model class from conduct model that user. That's great. And since we have an interface, we also need the implementation for this soil create on additional package called Comb. That service that I m pl and under this package will set up a new class called User Service . I am peel. Okay, so this user service I am peel needs to implement the user service. Let's import user service. And also let's implement the fine door business logic. So far, I don't want toe return. Nool. Uh, just let's creator new least off users on empty, leased off users. And let's return it, at least for the moment, okay or a list. I import it. Palestina released and just returned or users list now we need to tell spring that this will be a service class. It's, ah, spring specific stereotype that will tell spring that under this class will have business logic. Now, since you have the interface in the service willing to implement and basically create a new class for the user controller okay, under combat control, you see that I created this class less till spring that this will be, ah, arrest controller will be on entry point from our client toe our application and then two point will be local host 80 80 And let's set up AP I got a B I slash users over here. Okay, Something like this should go now. We need to implement the find all method. We're eternally stuff users under this final method will involve the user service to extract that empty leased off users when he poured Java Util list. But before actually using the user service, we need toe injected under our control across using the auto wired connotation. Basically, spring will know that behind the scenes were want to use the user service. I am peel corresponding class and let's invoke user service that find all and also return this and the list. Now it's important to tell spring that. Well, executor, get a request for this mental. I think we are in a good state now. Okay, So once again, we have this fund or method in our controller that use his user service injected. Using auto wired is user service interface has find all method. And under our user service, I am peel. We have on implementation for this method and user service. I am peel. It's a service class. I just started the application once again since I want to see the final metal in action, even if this method does not actually return any users. And let's invoke local host 80 80 AP I users. 11. Create random list of users: for this video as you guys. My No, We're currently returning on empty leased off users, so I would like to set up our random least off years or somehow So let's go under user service. I am pl And could he ate the new list so public least fusar users list equal your A list. So currently, dis list this empty and that's also at the static keyword for this list. Since I want this list to be populated once this class is initialized and over here I would like to sit up early. Um, a list of users. So let's also add the private integer i D. Since this will be used to identify each user that's had the integer idea. Under our argument, Constructor set up a value for it. I was so Oneto generate getters and sitters for the new field. Okay, and it's also important toe update hash code equals and to string methods to include this new field, so source generate hash code, any quarrels. Basically, this will override the existing methods. Think real door so di di go back to source jury to string and also overwrite the existing toasting method to include also this Newfield. Okay, the string equals equals sent hash code. Okay, They have the in your field. That's great. Let's go back to the user service. Same pl and I also want to control the I de toe basically increment it on each user. So I would I want to add a counter that will start from one and under the static block. We should basically create the list off users Armento, chrome, end type, juried, random name, since outright to use specific service that will generate some random names from for me that I can use for force name, Last name. We can use some think like, OK name, generator that will work. Let's go with the character name except that therms. Honestly, I'm not very interested in this field, so let's just generate some character names. I accept. And you see that this website journey that some names for us that we can use to create our users. So let's do something like user users. Least that ad on user and we need to create this user such as user user equals news are will set up the counter and also increment it automatically for the next user. We see the first name, last name, age and country are required. So let's take some names from this website such as I don't know. Yeah, we'll go to Yeah, we can use Georgiana Orgun Ortega, 24 from Brazil. Let's say let's also create another user at the counter Plus plus over here. Let's go back toe chrome or osas sparks. Okay, Does this Rosa Sparks? Ah, no, No. 34. It will go. I'm just adding some random countries and the random ages. But for the first name and last name, I just wanted to use a specific service from from Chrome that I found that's at the user toe. The list. Escape the new user. We'll go it or la McCoy counter plus plus or, uh, Goi. Let's add 19 and she's from USC. It's Formato beat the coast. So we currently have three users and maybe a final user. Here's our new usar counter plus plus. So let's go big down and use. Yeah, this should work, jury and, uh, yeah, that's the name 42 and she's from Canada. Let's add the final user under the users list. Okay, so currently under the users least will have four users. Each one will have ah, different I d. So on the find. All mentored. Let's use the users list that we just created. They remove this list. Okay, so find all returned The users list that we had created on the static block. Let's start the application once again. Spring with publication is starting. Okay, so the service has started. We can go to Chrome. And now if we select a P I users, we'll see that we were able to retrieve the list of users. How? Four years or so over here. 12. Use Postman to invoke Find All Users API: on this video last four start toe. Remove this slash from the a p I users. Since I would like to show you guys that we can invoke this local host 80 80 AP I users within without the slash at the end, it's important to set the substance. We want to prepare our structure for the newly created A B I's that will be sit under the's course. You can see that now they peer works with them without the slash. Now let's navigate the postman. Click on it. Postman is basically used for development to test arrest AP Eyes. We get great collections requests and so on. Postmen. It's loading now. That's what a bit preparing award space is great now still loading. Okay, now we can create a new collection here to store our request for our course. Let's call it spring. Boot her wrist. A p I Yeah, this will work. Yes, click on create And over here we can go and add a new request. Let's call it find or users saving toe this collection. We can open it. Let's go toe browser and Kobe this request and we can invoke it will see basically the same response that will see under Chrome browser. That's great. So from now on, we'll use postman to store our already Quist. Okay. And save this request or collection, okay? 13. Initial implementation for Find User By Id API: that's implement together Another AP I called find user by i d. So under user service will create a method that would return on optional off user called find by D. So this return on optional with an user so that we can prevent any no point or exception in case the user is not found We go now to use our service. I am peel and we can implement the business logic for find by demented so we can use optional off user is the opt users least Ah, we can do here. Ah stream. Since I want to navigate under this list and we can filter the list using something like user that yet I d equals with the I d provided us perimeter and find the first user that matches this. You see that we have some issues over here. This happens due to the fact that we set up a long s perimeter. But our user has ah integer. So we'll just change the integer from our user model to use the long update The getter and setter methods. Okay, does go back to our user service time peel and you can see at the top here that we used when integer for our counter. Let's fix this. We set up as long and it works now. Good. So let's check if we were able to extract on optional with the value inside it. So user hoped this present Okay. If so, we returned the user optional, if not by default, were returning. Am Theo option. So now we can go on there are user controller and implement a new method to find user by d public usar find by a d was set The parliamentary us longer I d and well involved a user service find by D optional user is there optional. Let involved the use or service find by the with the idea provided us perimeter now it is are optional. It's present. We were returned. Ah, user. Okay, we can do something like return. Use the optional that get to extract the user from the optional and eternal. In this case, if we were not able to extract a new user also, it is important to set up the mapping and add the path variable to match the mapping as I d . Okay, good. I think we can do some refractory ization over here since by default we can return the user optional. Okay, from from this method. And in fact, let's do something like return user optional extracted from the users list and go back to the user controller. And over here we have this this validation we remain. Now let's start the application. So if we're able toe return on user optional or not will create Ah, this request find user by the let's call it fine by a D. Okay, And over here was the local host 80 80 slash user STE. P I users slash I don or let's type free over here. And you know that we have four users, and basically this will extract the furred from this list. Okay, So since we have this, um, this collection that is basically related to users bless rightto edit this request as find all and also added Eric with the collection. So something more something more appropriate. The users collection, such as users collection. So all requests are later toe users. So once again find all works and also fined by the works. Now we set up to that will extract the second user. If we sit up, then it will not show anything 14. Introduce ResponseEntity: I would like to introduce the concept off response entity under our controller in order through have more control over the http status coats. So for the fine by user method, our returner response entity with the question mark adjourning ST month and instead off returning user optional that get we can create a new response entity. And we can sit the body as use the optional that yet tohave some content to display. And also we can use http status as okay, This will map HDTV status. Go toe 200 instead of a question mark we can use And the user here less fix the state month . Okay? And instead, off returning No, we can t turn on your response entity with no content and we can set avoid here with http. Status not found. Okay, So if we're able toe extracting user 200 start to school. If not 44 now, we can also go to the find or method return Also hero response entity, Question mark and create the new response entity where we will set the user service, find all response under it, use their service find all okay and hash TTP that state owes that. Okay, so this will map also toe 200. Good. So both methods were outdated, not start the application. Okay, lets wait for this to start. Great. It started. Now let's go to Postman and use the free for the find user by d We can see that this was returned. Since we have four users, the second user okay, and you zone I d. That does not exist. We can see that four or four has bean returned and the find all mattered returns the list with 200 as status scope. 15. Implement Add User API: That's more four guys and implement on add user a p I. So under our user service were greater. Add method. Use a user Okay, on there are user service. I am peel. Let's import okay, that mattered and implement it. So for the users least will just need toe ad at user toe the users list. Okay, And we also need to take care off the i d and used this camper in good. So let's move under user controller and use the post mapping. Since this AP, I will be invoked using post method. So post matting post mapping slash AB. We're also return a really response entity for this method. Let's call it ad. We'll set up the user user over here, so this method will be invoked using on user as body will invoke user service, not add user and just returned. Ah, new response entity void http Status and use created that status schooled, so created will map toe, toe, one start scope. So next we need to set up some specific at Riboud's. So for the user, we need to set the request body so that spring will be able to interpret the user and we can also add some validation toe This user, such as we will expect the first name last name, age and country being being set for for the user as mandatory fields. We're not interested in the i D and let's use the valid a notation toe. Verify this user so spring will be ableto verify this user on the request. We're now ready. Let's start the application so the application is starting. Okay, let's move back Toe Postman. And over here we can create a new request. Let's call it. Had the new user save it or collection. We need to change the get the post and use local host 80 80 AP I users add Let's save it. What? We also need the body toe This ad ap I so we can just copy paste this as a reference goto body for a DP. I select Jerry son and we can remove this idea since this will be automatically set up for from our application. Let's add the new user her use my name age in country. Just one example. Guys, we need to invoke the send operation and you can see that the one status code is the return , and basically the new user has been added to the list. You can see it here with the I D five now. If we go back and don't add country for a user, you can see that the validation process kicks in and we have 400 about bad request. This happens due to this validation being added, not more. 16. Create Delete User API: under this video will create the delete user a p I. So we need to navigate back to user service, create the new method called delete. But let's also return an optional user here. Okay, so did it. Well, get from the arresting point. But I D. Since we want to know which user we want to delete from our list, let's add the implement that method and those so set up a business logic for it. So in order to the leader user, we forced me to find it basically see if the user it's present under our existent list. So create an optional off user called User Hope on and using the users list stream process and let's go filtering. And we want to find the user with the i D provided as request. So you need to check each user very fights I d and find first. Okay, now we need to verify if we have when user under our user optional. If so, let's return the use the optional back, and if not, let's return just on and the optional Now it's also important to remove the user from the users list, so let's use something like this Users list stream process. Okay, filter. I want to use this process just to show you guys that this can be done with the users list . Really move method, but also using the steering process. The job. Eight stream process from from from list and we need to check the user optional. Get that get I d equals users, get I d. And also core elect the state months as a list. But what we can do here is to negate the statements so well we will keep on Lee the user that don't have this, i d. So where he will have in our case on Lee three users instead of four if we provided valid the I D, such as 123 or four in the pyramid or as a request. So let's move to use their controller and create the delete mapping method for the Delete User service. A p I. Let's use something like the late and also the i D. So behind the scenes. In order to remove on user, we can evoke local host 80 80 um, a P i users and four, and it will basically remove the user that has the i d four. We set up the deal it method with the bat variable. And now we'll involved the user service deal it method that we're returning optional off user. Okay? And now we can check that the user the option optional user has a value and if so, will create a new response entity. And over here we can provide the optional user and 80 b staples such as Let's go, it don't know content. Okay, I changed the question mark to user. And if not, where it turned just a simple response entity. But this time with the http status such as not found and http. Status not not found. Okay, now let's start the application spring with this starting. Okay, let's go back to Postman and we need to create a new request. Let's call it the little user. We need to changed the method to delete and use local host 80 80 AP I users delete and four we can save and also evolved the p a. You can see that toe for no content. It's the return. And if we invoke the final method, you can see that we only have free user set up. Since the 4th 1 has been deleted. Another test. You can see that photo. Four not found 17. Implement Update User API: under these video, let's create together the final method for our karate P. I so does go on there, calm that service user service. And over here, let's set up when you met, called Update that will return on optional off user. And as arguments it will receive the user that will be updated. Okay, lets more under user service time peel and implement the new method. Let's move it above a bit right here. Okay, it's good, and we don't want to return more or anything related to this. But we also need to check if the user experience and under our list, and we can use something like this just copy place from the delete method. So this will check if our users list will contain the user that we want. What date and return the optional. That user. Ah, this should be used or that get I d. Okay. And if use the optional this present, we can extract the user from the user optional. Let's do this as 1/4 step. Use the optional that get and we need to Very far, which fields have been updated for the user that we receive as metadata argument so if user get force name, it's not equal. Tono. It means that the user force name has been updated. So said the existing user New Force name as user that get forced Name a similar process for the users. Last name Same technique will use such as existing User said the last name. Well, we received the value from the user. Last name. We have two more properties to set up aging country. So if user age it's not equal. Tono existing user set age will be user Get age in the final property. This is for country, so users get country. It's equal, it's not equal to no existing user said Country will be the user that get country. Now we need toe update Somehow the users list with the new user. But for this we can use on Internet of approach, such as very moving the user that we found from the list and basically re adding the user at the end off the list. Let's go with something much harder. Let's say so. Users least that stream that's filter on the list off users and let's go with this now and we need to negate the operation here. So were we were received. Only the users that don't have the who's our i d received US method argument and we need to create a new collection. So Collector says, to least and now we have created our new users list and on the user's least just add the existing user. Basically, this existing user with will be, in fact, top dated user so we can format a beat, this cold strain filter and now the collect operation. Okay. And we need to return the existing user. And also actually, we need to return an optional here. So let's do something like this optional off existing user. And if the user was not present, we return on optional off empty. Let's do something like this so optional dot empty and that's basically it. So K users list will be updated with the new. Yours are where they told the properties that are present in the user provided as argument and okay, we need to create Ah, you met that under our controller. Let's call it put mapping. Since this Ah, the statement this required for STP I to ah be work with the put operation, so slash update This were Returner Response Entity. The update method created similar to the add operation will have a response. Body off. User user You can see that we didn't set up the varied operation here since valid The statement here, since we will allow the update Operation toe not sit all the mandatory properties. So no if from the user service update method, if we got the optional off user, we're returning a response in teen entity off user with optional Fuser Thought get And the http state to school does okay not content. Sorry. And if not, we return no response entity with void in a city with status that not found. Okay, so we're are in a good state, so we will just start the application once again. As I told you guys, we did not have to set up the valid statement under our request. Since we're allowed the user Toby updated turns off first name, last name, whatever we want. So we can go on their postman and create a new request less college Update a user. Let's change the operation Toe put. This will be invoked by local host 80 80 AP I users update I was just save for now and let's first in photo find all AP I You can see that for the i d. With one. We can cope. Replace that state month go under our update operation for Body Select J Son and Kobe Paste . Here. Let's change the age 28. Extend off. 24 will have 28. Let's involve the rest. AP I. We can see that toe for no content has Bean returned. And if we will walk once again, find all AP, I you can see that. No, no, no, that's not the one we can see that the bottom. Since the list has been updated with a new user, we saw that the age has been set up to 28. Well, we can go back and just toe sorting for our final AP I using a comparator that will compare our users based by I d. So, even if we add a new user at the end of the list one way out dated on the final AP I this will be shown as sorted by by 80. So collect collectors to list. Okay, let's restart the application once again and see how things go now were involved. The find all AP I go An update on user the same user with Ah, I do want an age 28 invoking the final AP I Once again we'll see that the list is sorted by D and ages 28 for the 1st 2 user. 18. Introduce Spring Data JPA and H2 Database: were introduced spring Both data G p A and H two in memory. So I went to Google and type in Ah, spring Boots starter Dave Data G P A age too. On the page that opens, we can select the first item And what I'm searching for is yeah, these two dependencies Springboard Starter data G P A and the the age to corresponding that obeys all copy paste this too, and goto our home file and I want to remove the versions Is this version will be just related by spring will save the poem file and behind the scenes If we don't have ah, spring will start of data JP and age toe corresponding or jar falls there will be automatically downloaded by spring using Go May 1. I want now toe application properties and define a bunch of property such as that the suits you are ill that that's was driver Name that a suits user Password GP database platform G P . Eight show a school ST Month. This property is required to update the entities this one to enable age to console and the last one to set the said the age to Toby on the customizable You are ill now. I just started the application, and if we take a closer look under our logs, will see something new here. Maybe you guys paid attention. We'll see the age to console available at hace two u R l We'll see someone in formulated toe Spring J p. A. And now we can go on the local host 80 80 and never gato hate to, and the new page will open using these GDP. See you are that can be extracted from the application that properties from here. The user name and password will be able to log in tow our age to console using this in memory database. 19. Update User model class to an entity: we should move forward and that date our user model, class torn entity so that it will be visible under our age toe in memory database. So I went toe user class and right here at the top is important toe. Add the entity annotation. This will tell spring and behind the scenes that J p. A. That this class will be marked as an entity for the i. D. Will set the idea notation in the jury that value we can go with the identity jury value such as idea will be the primary key for or our model class and will be automatically increment ID by our in memory h two database. So I created. I set up the entity, the idea, the generated value and it's also important toe ad the user depository. So I created the com that repository package and set up a new interface called as mentioned user Reports story that will be able to invoke corresponding methods using spring data J. P. A. To our database. I added the repository annotation, and this class will extend the crowd repository using user and long as the model and the primary key that we will use, so you can see that we can also add the additional annotation over here. Let's call it table and the table name will be set. US users. Yeah, let's go with users. Okay, so I think will we are ready to go. I will say the user depository. So once again, this user depository is an interference. But behind the scenes using spring that RGB we have access to a bunch of metals toe automatically call our in memory aged a database. Let's take a look a bit that the logs we can see now that a new table has been created called users the stable has been created automatically since now Spring knows that that ah , user table is annotated. With entity under age to counsel, we can see that the user stable is present. 20. Improve Find All Users API: Under this video, we will adapt the final user AP I toe work with spring data G P A. So let's go on the reserve service. I am peel in search for find or corresponding method and we see here that this currently takes into account a user spliced lose the static users list that is created on the application startup. So we need to first inject the user depository using the auto wired a notation so that we can use depository corresponding methods. And under user reposed toy, there is a metal called find all so we can invoke it to extract and basically return all the users. Okay, and this we don't need any more. However, we see an issue here that a terrible users first was leased off users. So if we take a closer look at this method, this returns of terrible least off users and comes directly from crowd repository. Please recall that are user repository extends the crowd repository corresponding interface . So let's do something like this under our user repository. Instead, off described the depository Let's extend the JPL reported story under GPL repository. We can see that we have access to pagination sorting and so on. And this extents off course crowd repository that had that terrible find. All Okay, good. So instead of find all we see that under GBH repository, we have the list. Find all that we can properly use instead off the a terrible find all from the Carod repository. So now the should work, as expected. I just started the application. Okay, so once again, I've done some lively factory ization for you to show how the final should be properly used . I'm invoking the final method and by default, there are no users into the database, so it will return on the list of users. Since please recall that we don't use anymore the static list off users. But instead we use the user repository toe, find our user, are our list of users from the database 21. Modify Add User API: Hey guys. Under this video, we will update the add user API functionality. So under the public void at mentor for the user user parameter, we remove this and we'll use the user repository safe method. And we'll pass the USA as a parameter. And we won't use the counter anymore. So now let's stop the server and start it again so that the newly added changes will be taken into effect. Wait for this to start. And let's go to Postman and forced invoked, find all users method. You see that the array is empty. Now let's go on the other new user. And we should check the body. For this. We don't need the ID since the idea would be automatically generated as format this a bit and invoke the single operation. So you see the status code is 201 Created. And for verifying this info dot find all law users metal. And also double check. We can invoke the H2 in memory database to do a select. And you will see that in the news or has been added. 22. Adapt Delete User API: under this section, let's update our delete user a p I to use in the newly created reposed story. So if we go on the user service, I am pale and search for the elite corresponding method. We don't need to use the users least stream anymore. What? Instead, we can use the user reposed authority and find a new user by i d. Once again, please recall that we haven't implemented this method. This will come directly from the spring data G p A. And if we found the user that we want to dilate were just deleted from the repository by user optional that get. And also we need to remove this users list state month and that's basically it. Now we have to restart the application and take a look at postman to do some tests. Went to Maine just sittings in action. Now the application starts up gauge the console that a base has bean. Actually, the table has been created, application has start and now we can review the find alot method was there are requests. You can see that the the requested returned returned on empty list. We can play with the ad operation and add a new user. Now move back to test and review the final. We can see that we have on user next to this. Let's also check the user stable to see just to prove that the the user exists. Select from users. Concede that the user is present over there. And now let's invoke the delete operation with the ICTY one. Since we can see that the newly created user had i d one that involved the our estate p I and you can see that tool four has been returned. Let's check once again to find all and we can see that we don't have any users. Also, same thing happens in age to counsel, so we were able to remove the user. 23. Improve Find User By Id API: under this video, let's update the find user by the A p I. So let's go to the user service. I am peel and the instead off using this users this stream operation, we can use the user repository find by a d a b i. And that's basically it. We can now stop the corn server and, uh, started once again. Now the application it starts takes a few seconds for the table. Toby created students once again. It's ah in memory aged a database. And now let's go to find all you can see that on em. Tillis is our returned. We can use the add operation to create a new user and find by the we can use the ideal the user that is one. So go back and we have one set up here and invoke the A p I and the user has been extracted 24. Modify Update User API: fourth is video. Let's modify our update AP operation. So once again, under user service, I am peel. We have this update operation that takes into a counter user splice. We don't want this anymore. We want to take into account a user depository and find on user bites corresponding i d. Now these operations were remained the same. In fact, since if we found on user, we want to updated based on which properties have been set up. We don't need toe. Add anything back in the user's list just to save the user. Save the updated user behind the scenes. You see that user reports story save operation. It's capable of figuring things out that the existing user has own I D on I D. That its present into our database and Spring Data GP a willow sort things out in terms off finding which user has been updated. Now that's your let's do an example for this. I started the application and let's add for stone Ah, on user. So, yeah, this user has been up. Us has been created. Let's, uh, let's review that the user is present in the list, okay? And we need to copy paste and do an update on the user. Let's of date its force Maim toe, Alexandra instead. Off off, Alex. So do the send operation. The call the sender bottom here two or four content has been ah returned. And you can see here that that date has been made also in the console and also in the age to corresponding. They will so select from users. You can see that the first name has been updated to Alexander so And if we do a find by a D Previously it was Alex. Now we can see Alexander being present. 25. Create mechanism to store users on application startup and refactor UserService: What we want to do now is toe have somehow least off users at application startup. Since you know that we don't take into account er users list anymore and by default we don't have any user set in tow r H two database. So we need to somehow get rid off this users list. So for now, let's commented. And that's also removed this state months since they are not required anymore, Really go on the, um source main job. Are you create a new package called Calm? That component? Let's call it component says. Basically, this will be, ah, component that will run automatically at the application startup. I will create a new class. This will be called load Users in DB okay, and this class were required to implement Cole Mont. Line Runner. Seems if a class implements this common learned runner, it will automatically Iran at application startup. We need to tell spring that this is a component so that it will be taken into account and we need to also injector private user depository using the photo wire, the annotation. Let's importance out and over here we can copy paste this users and also removed this state month since we don't use it anymore and go back to the load users in the big class and this just based things out now we need to first import the user and we see that we don't need any more this i d perimeter to be set up on the constructor. Since this will be automatically handled by the spring data, G p A. We also need to spread the move This set I d method and we're not able. We're now able to remove this counter and use their object. It is in a good state. Now that's also remove this user spliced que remove the counter. Another user object in a good state. Good doing some some of the factory ization now. Okay, so we have four users created. We need toe add all of them under our user stable, using the user depository save operation. So user reports stories say user, I will copy paste the state month and will have all user set up in our user reports story. Good things Looks looks good. Now, an important statement is to add the transaction annotation each and every time we have operations set up into our service or component operations related to our database. So all all this operation inside our own method will be executed in tow a transaction. Also, we can add the transactional annotation under our service method so that each and every operation from the service method will be executive in a transaction. Okay, And let's start the application. Okay? The application is starting now. H the consul dialect they will has been created and important. You can see four insert statements that will basically insert. Are our users in tow in tow? The user stable. So now if we do a find all operation, we can see that the users are present into our database in they are extracted here. So we have four users we can even involved are fine by the a p I. That's great. It works. Okay, We can do ah and use our e p I toe on status gold and invoke once again the final ap I and we can see the newly created user maybe do another test on Ah update user ap I You know that the newly created user has i d had i d five. It seems that it's worked as expected. Let's check once again cornetto our age doing memory database. Let's do a select from users and we can see that the less the less user has. Ah, 14. Amos Alexandra. We can see that the delete operation also works as expected and the final will have now four users. Since the previous one has been deleted, select all users. 26. Introduce Spring Boot Starter Security: as you can see in this video. First, I created a bunch off new users. We have 10 years, 10 users now in total. And the I use the user reports story save all 40 billion least of users instead off user depository, safe for each and every user. I think this will spit things out. And we're have also, um, bigger list off users that we can play with. Okay. Application has started. Okay, Great table. Illusory. And you can see that we have 10 insert statements over there on and go toe age to in memory database and was select for user stable. And we can see that we have 10 users now or so on the find. All on the postman. Yes, we have 10 users created, so that's good. The next thing is to introduce the springboard started security dependency under our palm file. So navigate to our phone file and or under here, we can create a new dependency, actually, Adamu dependency. So the group I deeds Orc spring framework in that booth, This will basically set up the initial security for our project. I'm searching for the Spring Worth Starter security dependency for you to auto review and know where I got this. Ah, this artifact from so springboard starter security. Okay, so once again adding this dependency will set up the minimum security that we can have for our project is behind the scenes Spring will be able to generate on user and the you i d that we can use to invoke our art. STP I I will show you guys in a minute. So I just started the application. Okay, creating the table. You saw that statement on there is a Spain point over here using jury the security password and basically this longer long string format. So now if we go and invoke argon although find user sapi I found all users ap I we can see that we receive 401 status code, so we're not able to involve the a p I. Since a minimum security for from Springer has been set up in place find by the a. P. I returns the same thing for a woman status code that we don't have for missions to to lack off out indication. So we can ah go on postman on a specific a be a request and goto authorization, Select basic authorization and typing user. And that that's worth okay. We updated the request than the invoke it. You can see that we're now able toe basically invoke the a p A. Since we added the user name and 27. Implement customizable basic security: under this video will not rely anymore on the default spring. Both security, but create our cost. The mall security from scratch. So we'll set up when you package name called Com. That configuration and the over here we can create a new class on. Let's call it security config. Okay, that should be good to go. This Ah, this closeness to be annotated with the enable Web security, this is ah, spring stereotype that will tell spring this that this class will handle the main business logic for our security Can see that this is ah, annotated. The configuration enabled global authentication and other security specific away concepts such as in memory security, different authorisation requests that can be implemented and so on. You can see that this class is, uh is ah, spin security related at the as the comments suggest. And now, since we created this security conflict, conflict less, we need to extend the web security config, configure a doctor, and we have some some methods that we need toe set up in place, such as, ah, configure public void configure that takes http security as an argument under this method, will set up different permissions for our, um, requests such as age two requests and also our a p i user request. So we can take the http security para matter and evoke the authorize requests. And based on this, we need toe have on and match er for H two in memory console. These two symbols will will allow every requests that come after h to Toby permitted since we ah, we added that permit all also another and match er can be set up for a B I users. Same thing for a p I users. Ah, match er that will allow ah will allow Whoa other formatted girls still Toby Toby set and accessible. Um, I had to create ah role such as Admiral and the A CTB basic as on ah authentication method will will show you how this would work and the next try in orderto toe properly. Access are este p I for this demo, I disabled the Croce iris request forgery. Okay, so can see that this requires to throw some specific exception. So I will throw the exception from this method. So once again, this is ah, minimum configuration, me mom. Custom configuration that can be set on extra point is toe allow age, too. Council Toby accessed. So I had to ah, get the headers, the frame options and also to the disable operation, since this will allow me to access the each to console Enbrel. So once again now let's do something like adding the configure global method and also dis acquires to be off the wire using gun authentication Manager builder. This will basically set up the user name and password Toby in memory and have the ad minerals role configured with it. You can see that I created the ought in memory authentication with user add mean password. Let's use the same password. And let's also set up a role such as admin that will match the role I added on the previous method. Okay, and this also requires some exceptional handling. So I just throwing the exception here, and that's basically it. Okay, looks good. Now let's go back to toe our application and restarted this will, ah, take a few more months or the application to start. So once again, I set up the minimum custom. Ah, secretly configuration. You can see that that password is not present any more scenes with Have admit that mean configured and let's go to our A p I and just invoke invoke it with the user and old password. We don't have access since we changed what may not mean. Let's use at mean for user. I mean, for password. That's update our requests and the invoke it. You can see that we received the 500 internal error coat that will be fixed in the next paedo. This is how this happens due toa password in colder that is not present in tow. Our application Basically we need toe in code. Ah, the in memory user password that we created for that mean unmin 28. Add PasswordEncoder mechanism: Let's fix the issue found in previous video by implementing Ah, across the moor Password in colder. So that's first Remove this and goto our calm configuration and greater new class called password config. Okay, over here we need toe Mark, discuss us. Ah, configuration class toe Be taken into account by spring and create a new being that will return a password in cold her. Okay, this should work. Let's call it the password in colder and as ah, basic password encoding met mechanisms We can use the big crypt. There is a class over here called Big Crypt Password in colder. So now we have ah password in colder set up. And we need to go under our security call thick and inject the password in colder using though toward annotation and his stepped off using the admin password without encoding will use the password in Golder encode method to in Cold the best warp Let's now start the application once again Days of your seconds toe to start up the service Okay created the user stable, we'll add although use ourselves application startup. And now if we of these the password here to use the at mean we can show the password that it's that mean and update the request involved a find your i p I. We can say that the issue has been fixed. Then we are able to extract the stuff a list of users so that 500 error code has been fixed using the password in colder. 29. Add Username and password fields to our User model class: Under these video, I would like to update a user model class to include two new fields. So outset up the not Nora notation and add a field called user name and also not know a notation for a field called past sword. Okay, we need to update our constructors to take into account these new fields. So string, user name, string, password. That's also add values to them. This past ward equals password was generate the get our sense setters for our user name and password when it was the i d. Okay. And it should be a good thing towards update equals hash cold. Matt, that's take a taken to a countess. This ah, new fields, just as a reference to caper give these methods in Ah, in sync with the fields and those. So let's also Oh, sorry. We don't need to What there is to use the gets the get i d. So I just wanted toe day that to string method. Okay. And now we went back to the load user Cindy be and we want toe add some some user name and password for our your source. Let's do something like this. Each user name Will will have the the first name in the last name. First letter. Let's go with something simple And for the password will use, um you idea random You i d and just converted toe to shrink. I will do this. Four Ole 10 users. So now, for the heart of user, they should be arose s and also the u i d Rammed on your I d to string. Okay, six more users to go. No, que or, um, you idea around them, you high tea the string. Okay. This should be Jerry age. You're right here. Your i d shrink. Okay, five more to go. You know, I d extreme. Let's do this for Abby now. Happy g. Staying over here very much. Should we have dated? Also was generate. Surround them random string. That's that will act as ah password for for all our users. Off course. Different passwords. I just tried to see more later user name and password here, So Okay. And the last one verone e ma on and let's at sea were here. Elio idea Random Your i d to think so all 10 users were updated. That's great. And now let's stop the application. We're started and they could look into postman to see how the final users AP I will will take into account also the user name and password for each Each user server is starting. Okay, good. So I went now toe, find all users invoking the request and we're going to see that you fields were added for each user. Good. Each off the 10 users have Ah has ah, user name and password. Now, if you try to add a user, it would fail with 400 bad requests that isco due to the fact that we did not set ah user name and the password for our user that now this feels are mandatory This recall that we sit not know And also we have the valid annotation in our arrested point for the ad operation. Let's go it I don't know something like this. Even if the the user name does not match, let's play a bit. Okay, that said that of the two John of the Toe Martine H. 22. And also let's update the country to your say and we'll have a new user created and on the final users, we have the password. He's shown as it is, it's not encrypted, so we need to fix this 30. Encode passwords for users created on application startup: Let's first fix the problem for password not being encoded on the application created that application startup. So I navigated to the users model class, and we're not able to use the password in colder over there. Since user is not the component recognized by spring boot, it's an entity. So since we are on the load, users in DB Class that it's a component, we can use the password in colder here so we can filter on the user's list and basically transform each user cortex wounding password to un encoded passwords and just returned the user. As you guys can see from this, we can collect the list off users and just regulate the list of users. And that's basically we need to start the application to see things in action. So Avery starting now will be ableto invoke the find all users a p I to see that the your I D. Is actually in colder now. Okay, great table users. Good. Let's go to the final user Safety I and we can see that the password for each user has been encoded. We don't see any more than you, i d. And now let's go to the user stable Cornick to the in memory aged with database, do a select to retrieve the list of users, and we can see that the past words are encoded also into user stable. 31. Encode passwords for user created on Add and Update APIs: under this video are also modified. The add user a P I and Abdic user A P I, such as the passwords, will be also encoded since currently, if we add in user or our data news or the password are not encoded, so forcing force on the ad operation before saving the user. We need toe set. It's password as the password in colder in code with the user cordant password that was extracted from the user object. It's important. Also, inject the password in colder Under the user service, I am peel using the OTA Ward annotation. Now the at method has been fixed and also on the update method. We need to first thing first ad. Also the user name and password Toby stored into our daughter basins way. Omit this so we will fix the this now. So if user get user name, it's not known. Existing user set user name will bay usar get user and the same thing for password. Now let's also say the past work as password in colder in cold use or get password. Okay, so and now saved the password for nearly grated user and updated users is in the encoded version off this password. Now let's restore the application. Okay? The process is starting with the embedded Tomcat server Fourth, the 80 80. Let's now go to adding going user, we know that the password is in clear text now. Oh, we need to also update our headers since postman It's out off sync. So on the authorization Basic What at me not mean Previ request has been updated. Send once again the request toe one status. Cody turn. Now let's go on the final users And we should have the newly created user next to the existing list and you can see that the password is updated in the encoded version. It's not in clear text anymore. Now let's go toe the update process and set up. I don't know another password in clear text such as thirst, new password in corruption. We involved the request. So for no content and if we do the find all, we'll see that the password has been updated and also encoded. Reportedly, let's get to the bottom and you can see the passport here 32. Introduce Pagination for Find All Users API: I would like to introduce the Yeah pagination under our final users, A p I, As you can see currently it will invoke the find all users FBI. We are extracting the entire list off users present into our data ways. So imagine that we have one million users. No server with will be a bit slow. So how can we fix this? Under our user controller, we can go on the find all ap I an insert a page, a bubble page of one corresponding reference that comes from spring boot and you can see that this page herbal interface has ah has specific features such a sorting pagination and so on. Now let's also add this page herbal under our find all method from our user service. So we're also important a page a ball here and we need to go under our user service. I am pl I also take this into account the page a bubble page double reference, import it and instead off using user reports story find all without the page a bubble. We just need toe use their user depository find all method with the page or reference added to it. This will not return our list off users, but instead a page off user. This comes directly from spring data G p A. We need to import things out and also fix our interface with this page. As you can see, this is ah Supplee stuff Least objects, okay? And we saved it. And also under our user controller, we should not return our list off. User, we should return a page here under our response entity. So let's stop the server and started once again to take into account this pagination process so you can see how simple or spring boot data G p a makes this. Ah, this concept off pagination we just need to add this page a ble reference in the return a page. Now if you invoke the find all oh users a p I we re thought now on Ah or eh off page is off references to be honest, off user and we see some additional feel setups that are page herbal total pages sorting Macon in total elements Total number off pages and so on. And we can even add some some custom fields on the request Such a spay judge one Saive size five. The page is a page number start from From Zero and we can see that basically, we extracted the second page. 33. Implement custom search for user based on criteria: under these video our implement or custom search criteria. Currently, as you guys know, we have only this find by users Find by I the a p I and I went in ah created a bunch of metals such as fine by user name Find by first name, last name, age and country under our user repository Over here on the reserve service I created find by corrected the a p I that takes the criteria and search item And under our user service, I am peel implemented the corresponding method basically based on the criteria User name, first name, last name, age and country really invoked the corresponding user repository ap I such as crime by user name for him by last name for him by first name find by age and find buying country You see that on the age I had to ah converted to ah number since by default it will come as a string Also I set up under the control a new method uhm for search get mapping that will take the criteria and search item request harems as mandatory fields and just invoke the service. You can see that a newly created AP has been sit on their postman. Let's give it a try. With criteria, user name and search item. Alex are you can see that it was able to extract data now for country and the search item. You say it returned the users that have their country set up, as you say. Okay. So we can also go with age and type. Search item 34. It found the user in tow That a base are 34. Maybe. Go it on A just to it should not find in anybody here. The list is empty and does something like this. Just four additional test. You can see that the list is empty and could not convert H two number. Message is displayed. 34. Migrate from H2 to MySQL Database: under this section. I would like him off the application from using H two in memory database, toe more popular database called my school. So, as you know, we have this users collection resource that extracts data from the age to in memory database. So I'm running now on example, and you can see data being retrieved. Also, we have access to the Page two console over here. So now let's move toe my school database. So I went on Google chrome and type in, download my school work bench and navigated to the four Sling. Over here, we can navigate toe goto download page. And between these two abortions, we should select my school installer community. Worsen. We started the download process. Wait a few seconds for this to finish and just double click on the installer. The installation process has started. There are a few steps that we need to follow. You can see the my school installer one that poor, and we should select the developer default person and click on next. Currently, I'm not interested in this requirements. You can click next and just click on Yes, and wait for this to finish. I speed up the video for you guys to see the final process. We can now configure the my school product. Oh, click on next. You see the default port being used Pretty pretty. 06 We need to set up on out indication method. Basically, we're required to type in a password. So I will use just the simple passwords. Keyword, click or next, my school service will be created. We are applying the configuration and the process should be completed. Now, we could go on finish now council and select the yes option in the task part. We should have a new icon and select manage. Instance the mice. Well, quarter pinching the mice Will war bench will be open and we need to type in the password, password and access our editor over here. We need to create the demo database. You see that? That you see, the database has been created. Now we need to configure our application to remove the age to corresponding properties and add the my school corresponding properly. So the first step will need to go under the pump. That exam ill a remove the age toe dependency. Instead of this, we need toe ad of my school specific dependency. So the group I do you will be my skill. And for the artifact, I t will use my school connector java. The next step is to go on the application properties and update the properties to use my school instead of age to so for the spring data search, u R l I will go with de DBC, my Skrill, local host, the my school corresponding port and the demo database that we just created. We need to update the driver class, name calm, my skill, the user name and password, our core ticked. Now we need to update our database platform to use or hibernate dialect and the corresponding mice will dialect at the end. We're not used these two properties anymore, So let's stop the server around the application once again. Since the application will now use the Maya skill instance in sense of the age to in memory database, the application has started. We should wait a few seconds. You can see that the user stable has been created and specific data has been added. Now let's check the my school corresponding instance. But first you can see that the dialect it's used as per my school specific dialect song. There are my school work bench. We need to first use the demote database and do a select from the user stable. You can see that up being inserted over here instead of the age to in memory database. And let's run a demo sample a P I data being retrieved now from the mice will database and everything works. 35. Migrate application to Docker Environment: as part of this video, I would like to move the application under docker Environment. Please note that you need tohave tucker install and configure on your environment as this video will focus only to emigrate. The application under Dr So I created the documentation file that you can follow and the initial step will be to create a network for both the containers for my school and also our application toe properly. Communicate with each other. So let's copy Paste the first comment that will create the network as the next step. We need to create a container to run my Skrill in tow. Four days. I want to hop docker dot com and typing my school to search for the my school image. Now we can create this container is Zinkhan Name my school database The network you resorts my school db We can set up some environment specific properties we need to use the My school database has demo since if you recall, use the demo as the data source, you are out, um I scwill image and for the version will use the eight person off the my school image. Let's typed in this comment and run it. This will create a container to run my school in tow. This will run off course in a demon mode. You saw the miners. The flag, they should be up, were running. And now the next step is to update our project for the spring. That asserts you are ill to use the my skill database that we set up for my school container. So let's do this. I went to the application properties, and you can see that I type in my school database instead off local host and the corresponding port. Now we need to navigate toe our projects structure, see the demo and typing in vain, clean package minus D skip test that will build our project. Okay, build success as the next step. We need to create a docker file for our project. So I went to in created this docker file under our project. Let's look at the doctor False structure. So I'm starting from the base image open J gate. That is ah, specific job image on docker hop. We can search for it here. Let's type in open J d. K. I'll copy from the Koran Project Target and the corresponding jar file. This jar file was generated when we invoked the Indian Clean Package Command. You can see it here, and the final comment is to start our jar file. Since we have the docker file in place, we can create an image from this Dakhil. While we can use this comment that will create an image called users Image. So let's copy paste this comment and typing here. This will create our image for our arrest. Ap I project using the docker file that I just showed you. We can list the images he was in docker images. Comment. You can see that the images in place users image. Now we need to create a container to run our image inside. So Dr Ron, minus the the name off the container, will be users Container. It will run in the same network as the My School and will be in the port 80 80 external import 80 80 internal toward Docker environment and will start for on the user's image. Dallas based this comment, and now we have a container set up for our application, also that were around in the same network as the My school container, who can see both containers happened running here. And we can also check the locks for our application container using the container identifier. You can see that the application has started under a container using docker environment. Last but not least, we need to update all our resources Toby into our docker corresponding i p address. So let's around an example to see that the application will run under the doctor environment now. 36. Prepare the server for UI interaction: as part of this video, I would like to prepare the environment in orderto be able to receive requests from on you I project that will build us part off discourse at a later point. So first thing, let's be sure that we use the spring that assumes you are ill for the local host, instead off the doctor environment. Now, if we take a look on the load, usar Cindy be would have on issue over here if we are using the my school instance instead off the age toe in memory database that we use previously. And I will show you how to fix this parts of the started application. And you see several concerts being made under the user stable. Let's go to our my school instance. Let's connect to it and let's connect to our demo database and was selected from our usar stable, and you see here that we don't have then no records that should be inserted only ones. When the application starts up, we have, for example, 28 and this is an issue that we need to fix. Let's first toe removed all the records from our user stable. You know, I have a clean environment. Does be sure that the truncate operation has drawn with success. We should have zero records. Okay. And now, in order to be sure that we have only 10 users set up or no, the application startup, we need to do a check such as the user reports story count operation. Sure, the return zero, if not, will skip this operation and we're not in certainly data. So let's test this. So be aware that we don't have any users at this moment and the 10 users were inserted week success. So it's good so far. Now let's stop the application and rest started. And at this moment, since we have 10 users already present it to the database, we should always keep that operation. And we will not concert any users anymore. So this has been fixed now, in order for our server applications. So this sprinkled application to be ableto received requests from on your application we need to set up being in place. So this is ah, method annotated with the beano stereotype, and we're eternal filter registration being off course filter. Be sure to import the spring for you, Mark. Corresponding. Go Beckett. Now we need to create on You Are are based course, configuration source. So I created this object and imported the corresponding package. Let's fix this. Okay, Now we need to set in place, of course, configuration object. And based on this course configuration object, we need to set some specific properties for it, such as? Well allow credentials. So we were also allow origins. And for this, we need to set in place of collections off single tonalist. And basically, this will allow origins for everything. That symbol means everything. And our courts configuration will allow methods similar to the previous line. Okay. And for the allows headers, we'll also need to set in place a single tonalist similar to the other previous two lines. Now we need to register the your outburst course configuration source with the course configuration, so that will accept everything and also the config object that we previously set up. Now, off course, we need to return a filter registration being that will be sitting place for our spring boot server project. And this filled a registration being the story. See, um course filter object off that source reference for the euro based cause configuration source. Unimportant step is to set the order for this filter registration being as highest presidents. And, of course, to return the bean. Now, let's stop the court on the running application. Let's go a bit under our security configuration and basically rewrite this configured method. So, http security that we receive us perimeter toe this metal when it to disable this and also set in place the form Logan, the looking process singer. Your girl will be set to Logan. So imagine that. Are your application that were right as part of the scores, Will you are now authentication. Toe this Logan page. We're also set the http basic authentication and for the and matters will permit all so all users will be able to access the logon page and for any other requests users need to be out indicated So at this moment, we prepare the infrastructure for setting up the your abortion off this course. So everything is in place for our springboard server project. So let's not get too local host 80 80 and you will see the default looking page in place place. I recall that we have the means apartment user impasse for let's navigate war prop for a p I. Who is he that this works