0:00
hi welcome back in this video I'm going to teach about the spring boot layer
0:07
architecture this is very must how the spring layer architecture flow working
0:15
if you know this chapter well the spring boot is very easy for you all to uh
0:22
build the application so you can see here there
0:29
is four layers those are controller
0:35
service repository and data source there is a
0:41
flow layers consist of spring boot layer
0:47
architecture so you can see here the front end front end which manage the all
0:53
the request what the requests coming to the front end it will be passing to
1:01
the controller front end can't passing the
1:07
data to the controller directly there another part which is a
1:13
DTO the all the data front end passing via the DTO
1:21
format front end passing the data to the controller via the DTO format what's a
1:29
DTO we will be explained in the practical session don't
1:35
worry about that you just keep in your mind when the request is
1:41
coming that particular data the request data will be passing to the controller
1:48
via the DTO format keep in your mind that is
1:55
must controller receive the data from the front end and passing the
2:03
data to the service service passing the data to the
2:12
repository what is the meaning by repository it is
2:17
nothing but managing the all the SQL
2:22
queries insert the record enter the record find the record all the SQL
2:29
queries managed by the repository
2:36
repository receive the request from the service and pass it to the data source
2:42
to add the record or delete the record or view the record whatever it is you
2:48
can use whatever databases you can use MySQL or MongoDB or post whatever
2:55
database you can use now you can see in between repository and data
3:03
source there is another thing which is a entity what is the entity mean this is
3:11
the table format of the database is a
3:16
table format of the database so repository send the
3:23
data through the entity to data source repository send the
3:30
data through entity format to data source
3:35
this how the spring layer architecture works now I'm going to tell you one
3:43
example this example which is very helpful you to learn the process of the
3:49
string layer architecture right imagine you have a
3:54
registration form registration form consist of many field such as a name
4:01
address phone number and email address once you fill the registration
4:09
form registration form is a front end once you fill Fill the registration form
4:15
there's a button which is submit click on the submit button the all the data
4:21
will be passing to the controller via the DTO of via the DTO
4:31
format receive the data from the front end from the front end to the controller
4:41
controller passing the data to service service passing the data to
4:50
repository repository passing the data passing the data to the data source
4:57
via the entity format to add the data into the database
5:06
now you have a clear idea the reg how the registration form flow
5:12
works passing the data what is the data we are passing through the DTO format to
5:18
the controller controller passing to the service passing to the repository
5:24
repository passing the data via the entity format to the data data source to
5:31
add the data if the data is added successfully the message will be passed
5:37
into the front end data save
5:43
successfully successfully register this how the spring layer
5:51
architecture work i hope you guys you have a clear idea about spring layer
5:59
architecture this is very much when we are doing the industrial project
6:06
we all the things we will be see in the practical session thank you for
6:13
watching I'll see in my next lecture hi welcome back in our last
6:20
video we taught spring boot player architecture this is very must to
6:26
develop the springboard application today I'm going to start the spring boot
6:33
application project so first I'm going to go to Google and type spring initializer okay
6:42
you have to type spring initializer right this is the website
6:49
spring initializer get start spring io click on this it goes to the
6:55
respective website for configuring your spring boot application project here the
7:02
project it defaultly select as Ruby you have to select as
7:09
Maven language keep Java yes spring boot you have to select as a
7:21
4 here under the project meta data here
7:26
you have to give the group okay this is the com example here you can this
7:35
default come as example now I'm going to this how the package has been created here you can see here the
7:41
package package name com example so here you can put whatever name you can put
7:49
your college name or your company name if you are uh imagine we are doing the
7:56
project for the company you have to put that company name also so I'm this is my
8:02
project so first application so I'm going to create here
8:09
springboard yes spring I just give as a springboard uh you can see springboard class just give a springboard
8:17
class okay package as as created as springboard class right here artificate
8:26
we have to give the name of the app i'm going to give the name this is my first project so I'm
8:32
going to use my app right now you can see
8:38
here my package is created like this way com dot springboard class dot
8:48
my package as created right so you can type com dot
8:55
whatever name you want okay if you are developing the project industrial standard for company you can put that
9:00
company name after that you can name it that uh if it is student management system you have to name it as student
9:06
management system app if it is a point of sales system you name it as point state system if it is a hospital
9:13
management system you name it as hospital management system like that i hope you understood so
9:23
far let moving to the packaging packaging you have to
9:29
select as jar you have to select as jar it's a Java version java version you
9:36
have to install the JDK7 this is the new version you can install
9:42
the JDK 17 you have to install after that we have to add the
9:49
dependencies you have to add the dependencies so first I'm going to add
9:56
the three most essential dependency those are click add
10:03
dependencies first web
10:09
second one I'm going to add as JPA which is nothing but managing the
10:17
SQL queries third one we have
10:22
to add as a MySQL this is for managing your database
10:30
service this is the spring web it will be managing your restful service there
10:37
are three dependencies this is a purpose purpose of uh managing the restful
10:43
service second one managing the SQL quer third one for the database management
10:50
system this a database what is a database you have created if if you are using the database as
10:58
poss database you have to add that particular
11:03
dependencies at the moment in this project we are using the MySQL database
11:09
so we are using the MySQL driver okay this this is the this how we have
11:15
configured the spring boot application project this step you must do it this
11:22
step you must do it project language and select uh as it
11:28
is what is the default it will select you select as it is you have to follow the step what I done the project under
11:36
the topic metadata what are the configuration uh I have done here after
11:41
that you have to select these three dependencies after that click
11:48
generate now here your project is here your project is created successfully
11:56
here this is a zip file here this is a zip file i hope you guys you understood the step
12:03
well i'll see you in my next lecture thank you hi welcome back in our last video we
12:11
saw how to generate the spring boot application project we have downloaded
12:17
the generated project we have downloaded this project zip file i I am
12:24
going to copy and put into my favorite drive so
12:31
you can select whatever drive you want so I'm going to put into my G
12:36
drive i'm going to paste paste on here so here this is
12:43
Maya now this zip file I'm going to make
12:49
it as a normal folder so I I won't extract this so if you are not installed
12:56
the vinear software you must install then only if you right click on this
13:02
folder you can see here this option will be there so I'm going to extract
13:09
files click okay now here this file now
13:14
extracted well it become a normal folder
13:19
so if you double click here inside this folder we have a Maya this file we have
13:26
to open on the Intel J idea we have to open on the Intel J ide so let
13:33
me I'm going to open up my IntelJ this is the editor where used to
13:42
write the spring boot application this is a professional editor for writing the
13:47
Java application books now I'm going to open up my
13:52
project into my Intelli idea so what you're going to do is go to the
13:59
file open option here you have to select where
14:05
file is resided here you can select it where your file is resided so my my file
14:11
is resided on on the G drive so I'm
14:16
going to go to the here this is your all the uh folder is show your all the
14:23
drives here I have put into my G drive so select the G drive click on this arrow to expand it so what is the name
14:31
of your project you have to select my app so you have to you have to select as
14:37
my app here this is some my app here some my app this is my project my app
14:42
click on here don't open this one okay this is this is this folder you don't
14:47
open it here go inside here inside you can see here this is this is our
14:54
uh project inside this folder we have another folder which is a Maya that
14:59
folder you have to open it you must open that folder don't open that folder
15:04
inside this may my folder there will be another folder called with Maya you open
15:09
this folder inside this folder we have all the project is there click okay trust
15:17
project i'm going to open up this window now you have to wait until all the you
15:22
can see the task bar all the dependency what are the dependencies are selected all the dependency will be
15:29
installing right you have to wait okay okay you can see this all the things will be installing wait okay it
15:36
installed successfully here you can see this is your folder structure you can
15:43
see i hope you guys you understood well i'll see you in my next
15:51
lecture hi welcome back in our last video we saw how to open the project
15:57
into Intelj ID let's continue the video
16:04
so here this is my project name my app you can see here this is the name which
16:09
we given in our spring boot application so this is
16:14
the name we have given while we while configure the project here you can say inside the
16:20
project you can see here there will be the folder which is src inside the src folder you can see
16:27
here the main folder let me expand the main folder we have a two different file one
16:35
is a Java another one is a resources you can see here if you expand the Java
16:42
folder you can see here comr
16:48
bootclass.mmyer this is the package we created here this is the package we created inside the Java folder there's a
16:56
package has been created com springboard class
17:02
may this is the package name we have configured uh while we configuring the project big
17:08
game inside this package there will be the class which
17:14
will be created defaulting my app application if you double click and open
17:19
up here inside this class we have a main method you can see the main method
17:24
public static vid main this is a main method that will be created that's
17:31
it right after that you can see here
17:37
there will be the another folder which is a
17:42
resources this resources folder if you expand it you can see here there are two
17:47
various folders static and templates there is another important
17:53
file which is application.properties this file which will be used to
18:00
configure the database connection we'll we'll see in our next video how to
18:08
configure the database connection how to create the database all the thing we
18:13
will be discuss in my next video right now let's look at that another important
18:20
file you can see here there is a form.xml
18:25
text this is a very essential file of the spring boot
18:33
application if you open up this file you can see here the dependencies you can
18:40
see the dep area called dependencies what this all things are uh string
18:46
configuration what are the configuration you are did while you creating the generate the spring boot application
18:52
project here you can see here is a package artificate ID here what is the
18:58
version all the things are here Java version what version you are selected all the things are there after that you
19:06
can see here there is a section called dependencies dependencies we have we
19:12
have added the three dependencies while we generate the spring boot application
19:18
those are JPA MySQL connector and web you can see
19:25
here this is a JPA dependencies this is a web dependency
19:32
this is a MySQL connector dependencies the the three dependencies you can
19:39
select here there are three dependencies is there you can see here if you want to
19:45
add more dependency you have to add it here inside this in this in inside this
19:53
dependencies here if you want to add any other dependencies you can add it over here later we will see how to add the
20:02
dependencies i hope you guys you understood the things well i'll see in my next thank you
20:11
hi welcome back in this video I'm going to teach how to add the
20:18
dependencies so here imagine you have to forget to add the dependency as
20:23
MySQL so how to add the dependencies so you go to the
20:29
Google you have to type
20:34
mvn mvn maven okay maven you have to type MySQL
20:42
connector connector press enter key on your keyboard here you can see here
20:48
there is a website which name is Maven repository click on this first
20:57
link it will take you to this page for getting the dependency you can see
21:02
there are dependencies here there are many dependencies there now you can see don't select as the first one to this
21:10
ones okay you have to select as below version so here you can select this uh so here will be selected this okay here
21:18
you have selected this right 8.020 0.20 you have select this one okay you can
21:24
select one of these what a problem no problem you can I have selected this you can see
21:30
here here some me here you can select the me dependency you will be able to select here you can select it here the
21:39
dependencies so here how to add the dependencies so here I'm going to remove
21:44
this MySQL connect dependency
21:49
i have remove it so after remove it I'm going to apply here the me whatever changes you are delete in the home.xml
21:56
XML file it ask to it if you have to click this button to ch load the changes
22:04
to apply if you click on this the changes will be applied here now the changes will be appeared the changes
22:10
will be app right now I'm going to add this one so here this one what I'm going
22:17
to do is I just copy it select I'm going to select it copy right
22:24
click copy back to my int ide file you have to paste inside this
22:32
dependencies okay I'm going to paste inside the dependency i'm going to paste it that's it i paste it after paste it
22:40
don't forget to click on this button you have to you must click on this button to
22:45
apply the changes generally the changes will be applied in your project
22:50
if you if you are not if you forget it it it won't apply it won't work so if
22:57
you click on this now you can see the dependencies this dependency is applied okay now the dependency has been applied
23:05
perfect right now here dependency has been applied successfully this you have
23:10
applied the dependencies if you once you forget the dependencies you have to uh apply the dependency you have to get the
23:16
dependency like this okay so this how we have get the
23:22
dependency i hope you understood the things well there is a site which is a
23:27
maven repository thank you for watching i'll
23:32
see in my next lecture thank you hi welcome back in our last video we
23:40
talked about the how to add the uh new dependencies in this video I'm going to
23:47
talk about the data base configuration part that is very important
23:55
part here we already we have add the dependency
24:00
MySQL connector dependencies now let me see how to create the database
24:09
so in order to create the database you can you can you go to the src
24:17
folder main here you can see the resources file
24:22
a resources folder inside the resources folder
24:27
consist of two folders and one file which name is
24:34
application.properties here I'm going to add the configuration part of the
24:42
database let me see how to add the configuration
24:47
part double click and open that here here first what you're going to is
24:54
we have to type the name of your project what's the name may my app so I'm going
24:59
to type spring you have to type string dot
25:06
application application you have type application dot name you have to name
25:13
your project what is a my app what's the name you here you are gave the same name
25:20
you have to type press enter key after that we have
25:25
to define the port where you running your app what the port you are declaring
25:31
Here I'm going to declare the port so you have to write server dot port you have to
25:39
write I'm going to declare the port 8080 you can declare whatever port you
25:46
want this is the port where my application is running you have to give the
25:52
port after that I'm going to write the database creation part here first we
25:59
have to write the spring dot jpa
26:05
dot hibernate d auto equal first we have to
26:13
write create first time we have to create the database so we have to use this code to create the database you
26:19
have to use create after that we have to the second line we have to register the
26:26
MySQL driver we already we have to add
26:31
the dependencies of MySQL driver dependency already we have added on the
26:37
home.xml file now here in application properties we have to register the
26:43
particular driver so how to register you have to write spring dot data
26:53
source data source yeah you can get it spring data source
26:58
driver class name click on this now here you have to write com this register
27:05
drive com dot mysqr dot
27:11
cj dot here it will be telling how to write it here cj dot J
27:18
DBC J DBC dot driver you have to write
27:24
driver this how you have to write it that's it press enter key on your keyboard right now you successfully you
27:31
have to register the MySQL driver right after that we have to tell the location
27:38
where your database is created right so if you have not
27:43
installed the MySQL workbench on your machine you must install the MySQL
27:50
workbench mysql workbench you have to install in your machine this is MySQL workb I already installed so this is a
27:58
port where my MySQL workpatch is running uh while
28:04
installing the MySQL work patch I gave root is a username password is a root 23
28:11
okay that's the username and password I have gave so first I'm going to here
28:16
edit group one right I have logged in the MySQL web page this is my MySQL
28:25
workbench right now what you're going to do is I'm going to create the
28:30
database so how to create the database so you write spring dot data
28:38
source spring dot data source here spring dot data
28:45
source dot URL you write URL here you have to
28:52
give the path you have to write J
28:59
DBC colon you have to write my SQ SQL colon
29:06
slash you have write a local host I'm using the local server okay local means
29:12
this our machine local host port what's the port colon what's the port my
29:20
uh myql work patch running this is the
29:26
port 36 so you have to write the port correctly there if there is any port
29:33
it's running you have to give that particular port right perfect slash your database
29:41
name what is the database name you are going to create right now I'm going to
29:47
create my database I'm going to create my I'm going to create my test this is
29:54
my database I'm going to create my test this is the database I'm going to create
30:00
on the MySQL database i'm going to create the MySQL database this is the database i'm going to create my
30:08
test right after that question mark you have to write create you have write this
30:14
one create database create database you have to write
30:20
carefully create database this is a capital letter create database you have
30:26
to write if if not if if not
30:34
exist the database is not exist it's true it will be creating okay
30:41
if the database is not exist in the databases it will be creating your new
30:47
database okay right that's the thing you have to write it this is your database
30:52
name here it will be checking is create database If not
30:57
exist right after that you have to write you have to specify the user credential
31:03
while installing the MySQL workb username and password so we write
31:11
spring dot data source spring dot data
31:18
source dot username you have to write it here root after
31:28
spring dot data source dot password we are using as a my
31:37
while installing the My school work batch I gave root one that's it that's the thing we
31:44
have right our mysql database creation part over now I'm going to create
31:51
another thing is a JPA configuration part it is nothing but SQL query
31:58
managing the SQL query we have to using JB so we have to write JPA you have to write here JP the
32:05
vendor adapter You have to write like this configuration you have to write
32:11
like this so we have to understand this line what what why we have write like line right uh this line okay JPA vend
32:21
adapter configuration part right so you write here
32:34
dot database database dot
32:41
Sorry database platform you you don't you click on this you have to get database platform this one database
32:48
platform equal you write dot hibernate
33:01
hibernate type carefully
33:14
dot write my SQL mySQL top right
33:23
57 dialect dialect that's it write like this okay
33:31
it's spelling message don't leave any message you have to write correctly
33:36
hibernate [Music] dialect and mysqr first after that we have to write
33:52
generate dl you have to write true this one you have to make it as true after that you have to write another line
34:05
showsql part also you have to make it as this is the things right so we no need to write this one you all you all the
34:12
once you written you have to just copy and paste and paste use your all the projects okay the first time only you
34:19
have to write it after that you have just copy and paste and uh run your projects okay this this this code I will
34:26
give you okay here you just copy and paste it you just you have to know how
34:31
these lines works that's why I I have XP right how the lines works this is
34:38
defining the port here we have to use register uh driver registration you use
34:44
the database if you use this this one you have to create the database after that we have to where your database is
34:51
created you have to given the path where your database created this a URL this is the user credential of MySQL workb
34:59
username and password this is a JPA configuration these all things you have to we have to consider inside the
35:07
application properties i hope you guys you understood i'll see in my next lecture
35:13
in text hi welcome back in our last video
35:19
we discussed about the rest controller cross region and
35:25
regress now let's continue the video
35:31
now you can see the class which name is test controller inside the class I'm
35:39
going to create one method which is a get text so how to create the method you
35:46
have to use public void i'm going to name the
35:53
method get text i'm going to name it as this method which name is as get
36:01
text inside method I'm going to create the variable string
36:08
variable my text i'm going to create my text
36:15
my test i'm going to create as my test
36:22
equal I'm going to write some text here i'm going to write this
36:42
application i write it after that I'm going to write the
36:49
system.out.printl to print this one system dot out dot print so in spring
36:57
boot we no need to write like this we simply we have short form you have type
37:02
s you have to type the letter s you can see here south you can write s o u s o u
37:11
t so it it will be pop up you just click on this one it will it will be
37:17
automatically imported right now here I'm going to write here you have to print out this text copy
37:25
this text ctrl C to copy and to paste here what I did so far we have to create
37:33
the variable my text so here we have to write the we have to
37:40
write the text which is a this is my first string application this text is
37:46
assigned to my test variable so this text I'm going to print
37:53
out below so you have to use it system out we have to print right so here this
38:02
is the method so this is a method we are created method which name is get text
38:09
get text method we are creating the variable my text after that we have to
38:16
print out the value that's a simple stuff we have
38:21
now this one we have to test it through the restful
38:27
API so how to test it through the restful
38:32
API so this is the get request so we have we have to
38:41
type this URL we have to display that what is the text you are typing here it will be
38:49
displayed okay this system.out.print what you are uh written
38:55
okay this this one assigned to this variable this variable pass it to here
39:01
it want to display so what you're going to is we have a mapping which is a get
39:09
mapping we get the request okay we will all the things we have later on we have discussed double step by step don't
39:15
worry about that so here we have to write the get mapping you just keep in
39:21
your mind what is the get mapping mean get the request from somewhere else you
39:28
have to get the request from somewhere else okay so here you get the regress
39:34
from this inside this function so we have to put get
39:40
mapping right so there are many mappings there are post mapping put mapping all the things we have discussed about later
39:47
so just keep in your mind the get mapping so you have to get what what is
39:52
the thing you have getting what you are written in the text this text should be assigned to this
39:59
variable this variable so here we have to print out below this text we have to
40:06
get so we write the get mapping right now after done the stuff okay we have to
40:13
create the restful controller cross request mapping after that we have
40:18
to create the simple you have to create a simple function right now I'm going to after
40:25
done all the things you have to run the application you again you have run it so
40:30
click select here click stop and return so you have to stop the application and
40:44
application right it will be running successfully if there is any error the
40:50
error will be displayed here so there at the moment there is no error right now I
40:56
have to check the request through postman so how to check the request through postman I'll be teaching my next
41:04
video tutorial thank you for
41:09
watching hi welcome back in our last video we tested through the API how the
41:15
API works using the get map right now let's continue the video now here if you
41:23
are this is the API if you are return and click send button your text has been
41:30
printed right now I'm going to create
41:35
another another function now I'm going to create another function you just copy this ctrl C to copy ctrl + V to paste
41:44
below here what I'm going to do is the same function I'm going to change the
41:50
name also here different name I'm going to give this function which name is get
41:55
text this function I'm going to change the name as get text one so here the text I'm going to change
42:04
it as this is my second spring application right now we have created
42:11
two different function first is a uh get text second one is a get text one we
42:17
have created the two different function let's execute the program and
42:22
check it what the output would be so here at the moment there is error
42:30
display so here this error display right so we have created the
42:37
error display why this error display here here here is here so here you can see here get
42:45
mapping get mapping but when the API runs we have a two different function is
42:52
there so here we have only one function that's why it will be executed this uh
42:58
this text now we have a two different function so how to do the thing is here
43:06
we have to write get mapping we have to write open bracket and close bracket we
43:12
have to give the path so you have to write first you have to write like this this is the way you have to write you
43:18
have to double quotation mark inside the double quotation mark you have to write
43:24
you have to write slash you have to write slash here you have to
43:30
write here you have to write get text you have write get
43:40
text one so get text one mean if the record is coming / get text one this one
43:47
should be printed you have to map it here write get mapping slash get text one this text has been printed here if
43:56
you write slash or write slash get
44:03
text to this has been printed okay so you have to write like this okay if the
44:09
method if you have to access test slash now you have write like this this this
44:15
you have to write like this slash get text you have to write like this this text has been printed if you write like
44:22
this it has been printed let me check now I'm going to again I'm going to run
44:28
the application right now let's check whether it's any
44:33
error comes there is no error here there is no error now let's go back to the browser now here slash your branch Right
44:41
what are the things we have written slash get text your
44:49
rights here one now you can see send
44:54
button here now you can see this is my first string application this has been
45:01
printed right now the second time I'm going to write this one should be I'm
45:07
going to change it as two click send now you can see here this is my second
45:14
spring application has been built now I hope you have clear understanding if the
45:20
request is coming / get text one this method should be
45:25
executed if the request is coming / get text 2 this method will be executed
45:32
that's the thing we have it right now here instead of
45:38
writing like this the professionally we have write the way like this you have to
45:44
write like this path you have to write path equal you have to get text here
45:50
this is the path okay we have give the path okay the uh API version test slash
45:57
this is the path we have to give the path this method will be executed
46:02
Right you can write it like this this way okay you have to know you can write like this way also this is the efficient
46:09
way you have right here have put it path here you can see path equal you have to
46:16
write get text now let's run and
46:27
check right it's working same same result
46:34
one now you'll be able to see this is my first spring application has been
46:40
printed this one printed now I'm going to execute get text /
46:47
two here here second one has been printed I hope you guys you understood
46:53
things well I'll see you in my next lecturing thank
46:58
you hi Hi welcome back in this video I'm going to talk about the return keyword
47:05
so here you can see earlier we have created two different function using the
47:11
white white if you are using the white when you are creating the function it
47:16
will be never written right this one we never return now if you want to return you already
47:23
study in your code Java you have to write here you have to write the data
47:30
type right you have to write the data type public string is a data type here
47:36
if you have change the data type here the error will be there so here what
47:41
you're going to do is you have to return you type the return I'm going to return
47:46
what is the thing I'm going to return my text my test text I'm going to return
47:52
that's the thing I'm going to Okay so when the request is
47:58
coming this text this text will be assigned to this variable after that I'm going to return
48:04
this one this how the function should be written so I'm going to this one instead of uh printing here console I'm going to
48:13
return this one into my postman postman two so what you're
48:20
going to do is I'm going to this one I'm going to remove it right now let me check whether it's
48:26
working fine or not now let's stop and run it
48:36
again right there is no error let's go here now I'm going to write get text
48:44
one send here this is my text my first
48:49
spring application it will be returning successfully so what I did here is so if
48:55
you want to return the this text we have written here if you want to put the
49:00
return keyword what happen is it will be returning to our front end application
49:05
so what are the things you have did you have to make the return so that it will be returning to the front end it will
49:11
print printing as a front end over here perfect now I'm going to return this one
49:18
so how to return so this one I'm going to remove it console console try now how
49:25
to return this now you have idea first how the method we have to make it as a
49:30
return so this this function okay so here keyword we have put it here this
49:37
one make it as string you put the data type string after that here show there if you
49:45
put the data type string the function we need to return
49:50
you have to write a return keyword return what thing you are going to return this text I'm going to assign
49:57
this variable this variable I'm going to return to where of runtime so you write
50:03
this my test that's it now let's execute the program and
50:11
check it what would be the output
50:18
Right now let's select two now the answer will be this is my
50:25
second spring application it print it has been printed successfully i hope you guys you understood things well i'll see
50:32
my next lecture in time