13. Introduction to spring boot

15 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€67.10
List Price:  €95.86
You save:  €28.76
£55.67
List Price:  £79.54
You save:  £23.86
CA$100.49
List Price:  CA$143.56
You save:  CA$43.07
A$111.96
List Price:  A$159.95
You save:  A$47.99
S$94.87
List Price:  S$135.54
You save:  S$40.66
HK$544.16
List Price:  HK$777.41
You save:  HK$233.24
CHF 62.56
List Price:  CHF 89.37
You save:  CHF 26.81
NOK kr792.29
List Price:  NOK kr1,131.89
You save:  NOK kr339.60
DKK kr500.54
List Price:  DKK kr715.08
You save:  DKK kr214.54
NZ$123.74
List Price:  NZ$176.78
You save:  NZ$53.04
د.إ257.07
List Price:  د.إ367.26
You save:  د.إ110.19
৳8,330.24
List Price:  ৳11,900.85
You save:  ৳3,570.61
₹5,945.56
List Price:  ₹8,494.03
You save:  ₹2,548.46
RM315.51
List Price:  RM450.75
You save:  RM135.24
₦108,149.19
List Price:  ₦154,505.46
You save:  ₦46,356.27
₨19,403.53
List Price:  ₨27,720.51
You save:  ₨8,316.98
฿2,393.75
List Price:  ฿3,419.79
You save:  ฿1,026.04
₺2,454.67
List Price:  ₺3,506.82
You save:  ₺1,052.15
B$425.95
List Price:  B$608.53
You save:  B$182.58
R1,282.09
List Price:  R1,831.63
You save:  R549.54
Лв131.15
List Price:  Лв187.37
You save:  Лв56.21
₩101,234.93
List Price:  ₩144,627.53
You save:  ₩43,392.60
₪254.67
List Price:  ₪363.83
You save:  ₪109.16
₱4,117.86
List Price:  ₱5,882.91
You save:  ₱1,765.05
¥10,949.58
List Price:  ¥15,642.93
You save:  ¥4,693.35
MX$1,405.49
List Price:  MX$2,007.92
You save:  MX$602.43
QR254.12
List Price:  QR363.05
You save:  QR108.92
P963.49
List Price:  P1,376.48
You save:  P412.98
KSh8,999.72
List Price:  KSh12,857.29
You save:  KSh3,857.57
E£3,561.31
List Price:  E£5,087.81
You save:  E£1,526.49
ብር8,689.79
List Price:  ብር12,414.52
You save:  ብር3,724.72
Kz64,250.82
List Price:  Kz91,790.82
You save:  Kz27,540
CLP$69,143.42
List Price:  CLP$98,780.55
You save:  CLP$29,637.13
CN¥510.67
List Price:  CN¥729.56
You save:  CN¥218.89
RD$4,244.94
List Price:  RD$6,064.47
You save:  RD$1,819.52
DA9,440.04
List Price:  DA13,486.35
You save:  DA4,046.31
FJ$162.13
List Price:  FJ$231.62
You save:  FJ$69.49
Q537.12
List Price:  Q767.35
You save:  Q230.22
GY$14,584.29
List Price:  GY$20,835.60
You save:  GY$6,251.30
ISK kr9,693.35
List Price:  ISK kr13,848.23
You save:  ISK kr4,154.88
DH701.59
List Price:  DH1,002.31
You save:  DH300.72
L1,285.64
List Price:  L1,836.70
You save:  L551.06
ден4,127.89
List Price:  ден5,897.23
You save:  ден1,769.34
MOP$558.06
List Price:  MOP$797.27
You save:  MOP$239.20
N$1,283.39
List Price:  N$1,833.49
You save:  N$550.10
C$2,565.21
List Price:  C$3,664.75
You save:  C$1,099.53
रु9,482.30
List Price:  रु13,546.73
You save:  रु4,064.42
S/259.58
List Price:  S/370.84
You save:  S/111.26
K282.68
List Price:  K403.85
You save:  K121.16
SAR262.90
List Price:  SAR375.59
You save:  SAR112.68
ZK1,929.21
List Price:  ZK2,756.13
You save:  ZK826.92
L333.95
List Price:  L477.10
You save:  L143.14
Kč1,686.22
List Price:  Kč2,408.98
You save:  Kč722.76
Ft27,781.83
List Price:  Ft39,690.03
You save:  Ft11,908.20
SEK kr772.17
List Price:  SEK kr1,103.14
You save:  SEK kr330.97
ARS$71,242.69
List Price:  ARS$101,779.64
You save:  ARS$30,536.94
Bs481.71
List Price:  Bs688.19
You save:  Bs206.47
COP$305,135.87
List Price:  COP$435,927.07
You save:  COP$130,791.20
₡35,171.10
List Price:  ₡50,246.58
You save:  ₡15,075.48
L1,769.55
List Price:  L2,528.04
You save:  L758.48
₲543,563.42
List Price:  ₲776,552.46
You save:  ₲232,989.03
$U3,109.25
List Price:  $U4,441.97
You save:  $U1,332.72
zł286.15
List Price:  zł408.81
You save:  zł122.65
Already have an account? Log In

Transcript

Let us get an introduction to Spring Boot. together that we will see an example of creating a spring application using Spring Boot. Water Spring Boot spring mode helps to create ready to run spring application. Spring Boot helps to bootstrap your spring application with the necessary data. What exactly is the meaning of it? Let me explain this in detail.

Till now whenever you want to create a spring application, you selected a simple spring Maven and you created the application. Once the application is ready, if you add in the appropriate JAR files in form dot XML, say if you want to work with Spring and Hibernate, you need to add hibernate jar if you want to work with spring as a MVC application, you need to add the appropriate dependencies in POM dot XML but with spring boat it is not needed. Spring this dot h wants started packages, Spring Boot application starter packages and Spring Boot technical starter packages. With the help of which the appropriate JAR files can be added. While creating a Spring Boot application, you need to select the appropriate application startup packages. Whether you want to add hibernate, our web couchbase or JDBC, or any other third party library, you can select it.

Once we have selected spring, a spring application is getting created with all the necessary JAR files without any conflict. That's what is given over here. You can add third party libraries without much fuss. Now actually you have created a Java application very used easily with all the dependent JAR files. Testing application also a Java application is ready. How to run it, you can run it as a normal Java applications are you can run it as a Spring Boot application, you can generate the jar file and run the jar file directly.

Spring Boot also has got command line support. That is what it has got CLA command line interface. With the help of this you can run the application. One way of being with the help of spring boots, you can also create a RESTful web service. With spring mode you can create applications that can be run as a simple Java application or a Spring Boot application are using the jar file of that application you can run it directly. With spring mode, you can also create RESTful web service.

This application can be packaged as a What are a jar file. While doing it I will just show you the different ways how to create a spring application using spring boots. How to create a spring application and package it as jar and run it as a wrestler. service. And the third thing is how to create a spring application and package it the server and run it as a web service. So these are the three main things, your springboard to create a simple spring application, your Spring Boot package is jar and run it as a REST service, then your spring boots package it as far as run it as a restful service.

So these three things are only the idea I want to learn with spring boots. Let us see the goals of spring boots. With spring boots. Your spring application development is made faster at all the configurations and unnecessary JAR files are added to your application. Spring boots also provides a range of non functional features. That is to your spring boot.

You can also add an embedded server you don't have to go in for an external Tomcat server. Because an embedded server will be attached to a spring application, then you these things can be taken care of very easily security metrics. takes an externalized configuration that is going in four separate configuration files. With Spring Boot, you don't need any XML. That is we are not going to have XML configuration data. Just with annotations itself you can create a spring application.

Let us see how to create a Spring Boot application, you can create a Spring Boot application from spring initializer you need to go to this link. And this is basically a window wherein you can give your project name you can give your package name, then you can specify what kind of packaging it is whether you want jar or what then you are going to specify the dependencies. Whether you want to add web module or hibernate or JDBC, couchbase or cloud, you can just select the starter packages. These are basically dependencies and then click Create automatically a spring application. Basically this boot application will be created with all the different JAR files in Palm dot XML, you will be having only this particular dependency if you want to have a web dependency This is what you need to add basically you will not be adding it it will be the A once you select web automatically it will be added to POM dot XML.

Once we have this added embedded Tomcat server also will be added that is why with a simple spring application you can just convert it into a spring REST service I mean RESTful web service Okay. Now let us see the Spring Boot application starters and technical status application starting just have a loop Spring Boot hyphen starter hyphen star star represents what kind of package you want JPA from couchbase rest JDBC there are much more why I will just show you directly. Similarly Spring Boot technical starters, Spring Boot starter JT if you Want to use jetty instead of Tomcat if you want to use laugh for j as your logging framework and Springwood starter hyphen logging. It is the default logging framework that is supported by spring which uses love back then springboard started Tomcat. This is using the default HTTP in in Tomcat. So when you're creating a Spring Boot application together with web app, by default Tomcat server will be added we will do is we will go back to eclipse Let me show you how to create a simple Spring Boot application.

To start with, I am not going to add any dependency because this is going to be a simple spring application. Now, I am an excellent I need to create a Spring Boot application. The Spring Boot application can be created in two ways. Either you can create it from spring initializer that is you need to open the browser and copy that link. A new window will open just like what I'm having over here or you can proceed with that Are you VST s spring tool suit is added to eclipse you can create a Spring Boot application from Eclipse itself directly. So go to File New other because I am in je Yes, I can just select spring.

Here I've got input spring Getting Started content spring definition all those stuffs I found typing spring I have got a big list I need to select spring starter project. Click Next. See the same URL start that spring that I will automatically it is getting imported only from there. Let me do the name of the project. Spring Boot basic. The type of the boot build tools that we are using his name as either you can use Maven or Gradle.

We are using Maven Java version is 1.8 packaging is Java language Java. Yeah, what is the I mean, group ID artifact ID that you can just give it over here. COMM dot example dot demos okay description demo project for Spring Boot. So this comes by the false so when you are going to open the same link in the browser, you will get a window just similar to this you need to fill in the values and there it says you will be having dependencies in case of Eclipse it is next. Now here, I need to specify what dependency a wants. Whether I want to work with iwo or no SQL or SQL or web.

I can just give it over here. I thought now I don't want any dependency. So let me click Next. And click Finish. automatically it will start getting imported from that particular site, a new Spring Boot application will be created. Now this is the Application Spring Boot basic, let me open it, I got palm dot XML, let me open palm dot XML found that XML you can just see this is the dependencies we are working with spring boots.

So I have we have got Spring Boot starter, we have not added any other dependency. But with the Spring Boot starter itself, you can create a spring application. In the previous case when we were working with spring Maven, we went and change the version here we don't have to do anything automatically. It will download only the latest one or the latest stable version. Now let me just show you the dependency hierarchy and teaching this dependency hierarchy you can just see Spring Boot started within which I have got spring core, the same version that we work with 4.3 point one two, I have got spring context, spring AOP. Can you see spring beans, spring expression, all these are from which modules that is from the core containers core beans context In expression language, so all the jar files relevant to that are added.

Together with that the logging framework also is added you can have a look the default logging framework supported by spring is log by classic which is added if you want to go in for any other framework other than log back, you need to add it as a dependency and it will be added to this application. So I hope this part is clear. So this is for palm dot XML. Understand this with the help of spring boots, you are only creating a spring application with the dependent jars just by selecting that spring started Spring Boot starter packages. In this case I have not selected any dependency it is a simple spring application. Now let me open SRC main Java, by default your file will be created.

Let me open this file, see the name of this file, Spring Boot basic application. What actually it is doing is it is trying to append the word application to your project name. The project name is Spring Boot basic together with that application is appended and it is creating your file a Java class with public static void Main. This is the file that is created and this is annotated with our Spring Boot application. This annotation is equal to three annotations are the red components can add the red configuration and add the rate enable auto configuration, you know what is the use of moderate configuration that is a file where you do all the beam definitions are the red component scans. What is the purpose of it if you want to identify the classes that are annotated with a direct component you need to use the red component scan are great enable auto configuration automatically they should be configured as being that spring beans for these purpose.

Basically they were using three Different annotations are put together with one annotation is at the rich Spring Boot application. Now, within this you can do fine beings from here you can call different layers. To start with, what I'm going to do is I'm just going to have a simple print statement added the parental and statements aware that I have got spring application dot run, the main method is calling the run method of spring application. This is to bootstrap this particular spring application and I have passed Spring Boot basic application class. This is just to specify that this particular class also is a spring beam because you have added an annotation at the rich Spring Boot application right. So this answer will be considered as a spring beam.

Now let me save this. I have to run this application how to run it. This is the simple Java application right because it is having public static void Main. You can select this file right click Run a Java application, our Spring Boot app, both are going to return the same result only. To start with, let me just run it as Spring Boot app. Let me maximize the console, you are just seeing the output.

This is basically a banner. And now let me just show you the output it is here. We'll come to spring and scroll to the end. You can have a look annotation config application context. What does this basically this is the IOC container. This IOC container should identify the beans that are available in this application.

When Spring Boot spring application dot run method is called the application is getting bootstrap as you are getting the output and see this class also is having a symbol because you have annotated with that the red Spring Boot application and you are saying the IOC container. This also is a spring bean. Now let me run this again as a Java application selected, right click Run Java application you can see the output. So there is no change in the outputs, you can run this as a simple Java application or a Spring Boot application. In this case, we have not added any other dependency like adding web so that we can just see how Tomcat server is getting started and running that we have not done. So, let me do a recap what actually we have learned in this session is water spring boots.

With Spring Boot, you can just create ready to run spring application. And if you want to add any external third party libraries, you can add them as dependencies. That is you're just specifying what are the dependencies you want automatically Spring Boot will be adding them as dependencies in bomb dot XML and add it to your application. We have also learned to create a spring application using Spring Boot. In the next session. Let us try adding all the concepts to a Spring Boot application.

Like adding scope, I mean lifecycle methods, then auto wiring all these concepts in a Spring Boot application and see how the outcome is going to be. Thank you.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.