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
€66.52
List Price:  €95.03
You save:  €28.51
£55.40
List Price:  £79.15
You save:  £23.74
CA$97.77
List Price:  CA$139.67
You save:  CA$41.90
A$107.48
List Price:  A$153.55
You save:  A$46.07
S$94.07
List Price:  S$134.39
You save:  S$40.32
HK$544.73
List Price:  HK$778.22
You save:  HK$233.49
CHF 61.85
List Price:  CHF 88.36
You save:  CHF 26.51
NOK kr773.61
List Price:  NOK kr1,105.21
You save:  NOK kr331.59
DKK kr496.19
List Price:  DKK kr708.87
You save:  DKK kr212.68
NZ$119.31
List Price:  NZ$170.45
You save:  NZ$51.14
د.إ257.07
List Price:  د.إ367.26
You save:  د.إ110.19
৳8,370.95
List Price:  ৳11,959.01
You save:  ৳3,588.06
₹5,916.42
List Price:  ₹8,452.40
You save:  ₹2,535.97
RM312.50
List Price:  RM446.45
You save:  RM133.95
₦117,624.49
List Price:  ₦168,042.19
You save:  ₦50,417.70
₨19,473.08
List Price:  ₨27,819.88
You save:  ₨8,346.79
฿2,426.48
List Price:  ฿3,466.55
You save:  ฿1,040.07
₺2,418.28
List Price:  ₺3,454.83
You save:  ₺1,036.55
B$406.67
List Price:  B$580.99
You save:  B$174.31
R1,268.60
List Price:  R1,812.36
You save:  R543.76
Лв130.09
List Price:  Лв185.85
You save:  Лв55.76
₩98,070.61
List Price:  ₩140,106.88
You save:  ₩42,036.26
₪261.37
List Price:  ₪373.41
You save:  ₪112.03
₱4,133.88
List Price:  ₱5,905.80
You save:  ₱1,771.92
¥10,806.63
List Price:  ¥15,438.71
You save:  ¥4,632.07
MX$1,423.91
List Price:  MX$2,034.25
You save:  MX$610.33
QR255.44
List Price:  QR364.93
You save:  QR109.49
P956.94
List Price:  P1,367.12
You save:  P410.17
KSh9,046.20
List Price:  KSh12,923.70
You save:  KSh3,877.50
E£3,475.04
List Price:  E£4,964.56
You save:  E£1,489.51
ብር8,733.50
List Price:  ብር12,476.97
You save:  ብር3,743.46
Kz63,853.79
List Price:  Kz91,223.61
You save:  Kz27,369.81
CLP$68,157.66
List Price:  CLP$97,372.26
You save:  CLP$29,214.60
CN¥506.84
List Price:  CN¥724.09
You save:  CN¥217.25
RD$4,224.90
List Price:  RD$6,035.83
You save:  RD$1,810.93
DA9,349.94
List Price:  DA13,357.64
You save:  DA4,007.69
FJ$158.89
List Price:  FJ$226.99
You save:  FJ$68.10
Q540.76
List Price:  Q772.55
You save:  Q231.78
GY$14,655.30
List Price:  GY$20,937.04
You save:  GY$6,281.74
ISK kr9,679.61
List Price:  ISK kr13,828.61
You save:  ISK kr4,149
DH699.78
List Price:  DH999.72
You save:  DH299.94
L1,274.52
List Price:  L1,820.82
You save:  L546.30
ден4,093.48
List Price:  ден5,848.08
You save:  ден1,754.59
MOP$561.60
List Price:  MOP$802.33
You save:  MOP$240.72
N$1,270.52
List Price:  N$1,815.10
You save:  N$544.58
C$2,577.69
List Price:  C$3,682.57
You save:  C$1,104.88
रु9,455.06
List Price:  रु13,507.81
You save:  रु4,052.75
S/265.82
List Price:  S/379.77
You save:  S/113.94
K281.99
List Price:  K402.86
You save:  K120.87
SAR262.75
List Price:  SAR375.38
You save:  SAR112.62
ZK1,938.58
List Price:  ZK2,769.51
You save:  ZK830.93
L331.04
List Price:  L472.94
You save:  L141.89
Kč1,685.42
List Price:  Kč2,407.85
You save:  Kč722.43
Ft27,354.11
List Price:  Ft39,078.98
You save:  Ft11,724.86
SEK kr771.99
List Price:  SEK kr1,102.90
You save:  SEK kr330.90
ARS$70,181.20
List Price:  ARS$100,263.16
You save:  ARS$30,081.95
Bs485.08
List Price:  Bs693
You save:  Bs207.92
COP$308,906.07
List Price:  COP$441,313.30
You save:  COP$132,407.23
₡35,572.52
List Price:  ₡50,820.06
You save:  ₡15,247.54
L1,770.13
List Price:  L2,528.86
You save:  L758.73
₲548,589.81
List Price:  ₲783,733.33
You save:  ₲235,143.51
$U2,994.50
List Price:  $U4,278.05
You save:  $U1,283.54
zł289.22
List Price:  zł413.19
You save:  zł123.97
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.