Show Topics
Hide Topics

Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can “just run“.

 

 

Spring vs Spring Boot

 

Spring:

Spring started as a lightweight alternative to Java Enterprise Edition (J2EE). Spring offered a simpler approach to enterprise Java development, utilizing dependency injection and aspect-oriented programming to achieve the capabilities of EJB with plain old Java objects (POJOs).

 

But while spring was lightweight in terms of component code, it was heavyweight in terms of configuration. Initially, spring was configured with XML & Spring 2.5 introduced annotation-based component-scanning, even so, there was no escape from configuration.

 

 

Spring boot:

project is just a regular spring project that happens to leverage Spring Boot starters and auto-configuration. Spring Boot is not a framework, it is a way to ease to create stand-alone application with minimal or zero configurations.

 

Finally, Spring Boot is just spring. Spring projects would not have any XML configurations as part of it, everything will be handled by the project Spring Boot.

 

Spring Boot Features

  • Create stand-alone Spring applications
  • Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)
  • Provide opinionated ‘starter’ POMs to simplify your Maven configuration
  • Automatically configure Spring whenever possible
  • Provide production-ready features such as metrics, health checks and externalized configuration
  • Absolutely no code generation and no requirement for XML configuration

 

 

We can develop two flavors of Spring-Based Applications using Spring Boot

  1. Java-Based Applications
  2. Groovy Application

 

Groovy is also JVM language almost similar to Java Language. We can combine both Groovy and Java into one Project. Because like Java files, Groovy files are finally compiled into *.class files only. Both *.groovy and *.java files are converted to *.class file (Same byte code format).

Spring Boot Framework Programming model is inspired by Groovy Programming model. Spring Boot internally uses some Groovy based techniques and tools to provide default imports and configuration.

 

 

Creating Spring Boot Application

To create Spring Boot based applications The Spring Team (The Pivotal Team) has provided the following three approaches.

  1. Using Maven
  2. Using Spring Initializer (http://start.spring.io/)
  3. Using Spring STS IDE
  4. Using Spring Boot CLI Tool

 

 

1. Spring Boot using Maven

Add maven dependencies in pom.xml & do maven build

 

 

2.Spring Initializer

Spring Initializer provides an extensible API to generate quick start projects. It also provides a configurable service: you can see our default instance at https://start.spring.io. It provides a simple web UI to configure the project to generate and endpoints that you can use via plain HTTP.

 

It will generate the Artifact.zip file, extract it and run maven build: mvn clean install package

 

 

3.Spring STS IDE

The Spring Tool Suite is an Eclipse-based development environment that is customized for developing spring applications. We can download it from here.

 

 

 

4.Spring Boot CLI Tool

The Spring Boot CLI is a command line tool that can be used if you want to quickly prototype (creates project Structure) with Spring. It allows you to run Groovy scripts, which means that you have a familiar Java-like syntax, without so much boilerplate code.

You don’t need to use the CLI to work with Spring Boot but it’s definitely the quickest way to get a spring application off the ground.

 

You can download the Spring CLI distribution from the Spring software repository:

 

SDKMAN! (The Software Development Kit Manager) can be used for managing multiple versions of various binary SDKs, including Groovy and the Spring Boot CLI. Get SDKMAN! from sdkman.io and install Spring Boot with

$ sdk install springboot

$ spring --version

Spring Boot v1.5.0.RELEASE

 

 

A simple web application that you can use to test your installation. Create a file called app.groovy as

$ spring run app.groovy

It will take some time when you first run the application as dependencies are downloaded. Subsequent runs will be much quicker.