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
€64.98
List Price:  €92.84
You save:  €27.85
£55.64
List Price:  £79.48
You save:  £23.84
CA$95.72
List Price:  CA$136.74
You save:  CA$41.02
A$105.61
List Price:  A$150.88
You save:  A$45.27
S$94.51
List Price:  S$135.02
You save:  S$40.51
HK$546.96
List Price:  HK$781.40
You save:  HK$234.44
CHF 63.39
List Price:  CHF 90.57
You save:  CHF 27.17
NOK kr759.29
List Price:  NOK kr1,084.75
You save:  NOK kr325.45
DKK kr484.72
List Price:  DKK kr692.49
You save:  DKK kr207.76
NZ$116.27
List Price:  NZ$166.11
You save:  NZ$49.83
د.إ257.06
List Price:  د.إ367.25
You save:  د.إ110.18
৳7,668.91
List Price:  ৳10,956.06
You save:  ৳3,287.14
₹5,843.17
List Price:  ₹8,347.75
You save:  ₹2,504.57
RM331.68
List Price:  RM473.85
You save:  RM142.17
₦86,437.65
List Price:  ₦123,487.65
You save:  ₦37,050
₨19,439.77
List Price:  ₨27,772.29
You save:  ₨8,332.52
฿2,571.29
List Price:  ฿3,673.43
You save:  ฿1,102.14
₺2,259.44
List Price:  ₺3,227.91
You save:  ₺968.47
B$355.04
List Price:  B$507.22
You save:  B$152.18
R1,290.39
List Price:  R1,843.50
You save:  R553.10
Лв127.12
List Price:  Лв181.60
You save:  Лв54.48
₩94,866.43
List Price:  ₩135,529.28
You save:  ₩40,662.85
₪261.89
List Price:  ₪374.14
You save:  ₪112.25
₱3,999.98
List Price:  ₱5,714.50
You save:  ₱1,714.52
¥10,762.93
List Price:  ¥15,376.28
You save:  ¥4,613.34
MX$1,185.03
List Price:  MX$1,692.97
You save:  MX$507.94
QR254.87
List Price:  QR364.12
You save:  QR109.24
P951.97
List Price:  P1,360.02
You save:  P408.04
KSh9,396.15
List Price:  KSh13,423.65
You save:  KSh4,027.50
E£3,355.96
List Price:  E£4,794.44
You save:  E£1,438.47
ብር4,011.08
List Price:  ብር5,730.37
You save:  ብር1,719.28
Kz58,466.37
List Price:  Kz83,526.97
You save:  Kz25,060.59
CLP$65,872.48
List Price:  CLP$94,107.58
You save:  CLP$28,235.10
CN¥495.49
List Price:  CN¥707.87
You save:  CN¥212.38
RD$4,060.47
List Price:  RD$5,800.92
You save:  RD$1,740.45
DA9,414.39
List Price:  DA13,449.71
You save:  DA4,035.31
FJ$157.07
List Price:  FJ$224.39
You save:  FJ$67.32
Q543.15
List Price:  Q775.96
You save:  Q232.81
GY$14,618.48
List Price:  GY$20,884.44
You save:  GY$6,265.96
ISK kr9,767.80
List Price:  ISK kr13,954.60
You save:  ISK kr4,186.80
DH704.80
List Price:  DH1,006.90
You save:  DH302.10
L1,237.78
List Price:  L1,768.33
You save:  L530.55
ден4,001.09
List Price:  ден5,716.08
You save:  ден1,714.99
MOP$562.43
List Price:  MOP$803.50
You save:  MOP$241.07
N$1,293.49
List Price:  N$1,847.92
You save:  N$554.43
C$2,572.34
List Price:  C$3,674.94
You save:  C$1,102.59
रु9,329.91
List Price:  रु13,329.02
You save:  रु3,999.10
S/260.85
List Price:  S/372.66
You save:  S/111.80
K270.11
List Price:  K385.89
You save:  K115.77
SAR262.50
List Price:  SAR375.01
You save:  SAR112.51
ZK1,884.87
List Price:  ZK2,692.78
You save:  ZK807.91
L323.24
List Price:  L461.79
You save:  L138.55
Kč1,626.08
List Price:  Kč2,323.07
You save:  Kč696.99
Ft25,316.43
List Price:  Ft36,167.88
You save:  Ft10,851.45
SEK kr757.73
List Price:  SEK kr1,082.52
You save:  SEK kr324.79
ARS$61,503.14
List Price:  ARS$87,865.40
You save:  ARS$26,362.25
Bs483.90
List Price:  Bs691.31
You save:  Bs207.41
COP$271,944.94
List Price:  COP$388,509.43
You save:  COP$116,564.48
₡35,713.67
List Price:  ₡51,021.71
You save:  ₡15,308.04
L1,726.17
List Price:  L2,466.06
You save:  L739.89
₲523,116.65
List Price:  ₲747,341.53
You save:  ₲224,224.88
$U2,673.86
List Price:  $U3,819.97
You save:  $U1,146.10
zł281
List Price:  zł401.45
You save:  zł120.44
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.