Home

Spring Boot Sample Application

Introduction
This artical provides how Spring Boot helps you accelerate and facilitate application development. Spring boot is sub-project developed by developers of spring framework – to create stand-alone, production-grade application with minimum configuration possible. Spring boot applications are typically bundled as fat/uber jar files and can be deployed in any platform as a simple jar file. This is why spring boot applications are a good candidate for building microservices in java. Let’s learn it by starting with a spring boot hello world application.
Overview
Features of Spring boot
v  Auto-Configuration - No need to manually configure dispatcher servlet, static resource mappings, property source loader, message converters etc.
v  Dependency Management - The different versions of commonly used libraries are pre-selected and grouped in different starter POMs that we can include in your project. By selecting one Spring Boot version we are implicitly selecting dozens of dependencies that we would have to otherwise select and harmonize ourself. Example-
v  Advanced Externalized Configuration - There is a large list of bean properties that can be configured through application.properties file without touching java or xml config.
v  Production support- We get health checking, application and jvm metrics, jmx via http and a few more things for free.
v  Runnable Jars - We can package your application as a runnable jar with embedded tomcat included so it presents a self-contained deployment unit
Implementation
Technologies used :
ü  Spring Boot 1.5.2.RELEASE
ü  Spring 4.3.7.RELEASE
ü  Tomcat Embed 8.5.11
ü  Maven 3
ü  Java 8
Create a Maven Project
Open eclips IDE, rght click select New à Maven Project. Enter Group Id and Artifact Id as shown below than click on Finish.
Open pom.xml and add below two entries. One entry for adding Spring boot starter parent and another entry for Spring boot starter web. These two dependencies are spring boot supported dependencies.
Create the SpringBootSampleApplication.java as below-
Add @SpringBootApplication annotation on top of class name.
This annotation enables below 3 functionalities.
1.      It will configure Spring boot configuration.
2.      It will enbale Auto configuration.
3.      It will enable Component scan.
Add SpringApplicatiom.run() method and print statement to run and print Hello Spring Boot message. This will be executed once your service built.
Right click on SpringBootSampleApplication à Run As à Spring Boot App. It will start your application and will execute your main method automatically.
Below we can see Spring Boot sample as been started and Hello Spring Boot message has been printed.
In below screen shot we can see tomcat embed server and spring boot starter jar has been added as maven dependecies. This will enable our spring boot application as micro service.
Download
S. No
Name
             Size
               Download
1
Spring Boot Sample Application.pdf
            400 KB
               Download
2
SpringBoot-Sample.zip
        8 KB
               Download

Comments