Spring Boot

Kasuni Madhushika
May 11 · 3 min read
Figure 1: Spring Logo

Spring Boot is an open-source and Java-based framework. It is used to develop “Micro Services”. Micro Services is an architecture that enables developers to independently develop and deploy their services and each running service has its own process. The “Pivotal Team” created it. Spring applications are used to create stand-alone and production-grade applications. They offer the Spring platform and third-party libraries.

Spring Boot is a hybrid of the “Spring Framework” and “Embedded Servers”.

Figure 2: Spring Framework + Embedded Servers

Uses of Spring Boot Framework

  • It has advanced database transaction management capabilities.
  • It provides powerful batch processing and manages REST endpoints.
  • It lowers the application’s cost and development time.
  • It includes Embedded Servlet Container.
  • It offers an annotation-based spring application.

How does it work?

Requirements

  • Java 7
  • Maven 3.2
  • Gradle 2.5

The Spring Boot Application’s entry point is the class that includes the @SpringBootApplication annotation. The main method of this class should be used to run the Spring Boot application. Auto-Configuration, Component Scan, and Spring Boot Configuration are all included in the @SpringBootApplication annotation.

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}

Spring Boot CLI

you need to use the following two folders:

  • spring-boot-cli-2.0.0.BUILD-SNAPSHOT-bin.zip
  • spring-boot-cli-2.0.0.BUILD-SNAPSHOT-bin.tar.gz

In the command prompt, navigate to the Spring Boot CLI bin directory and execute the command spring –-version to ensure that Spring CLI is properly enabled. Create a simple groovy file that contains the Rest Endpoint script, save it as “hello.groovy” and run with spring boot CLI. Then required dependencies will download automatically and it will start the application in the Tomcat server.

@Controller
class Example {
@RequestMapping("/")
@ResponseBody
public String hello() {
"Hello Spring Boot"
}
}

Finally, go to the browser and hit the URL (ex: http://localhost:8080/) and see the output.

Figure 3: localhost:8080

Advantages of Spring Boot

  • It provides “starter” POMs with strong opinions to help us simplify our Maven configuration.
  • Easy to understand and develop spring applications.
  • Increases productivity.
  • Reduces the development time.
  • No requirement for XML configuration.
  • Offers the number of plug-ins.
  • Offers a CLI tool for developing and testing the Spring Boot application.

Goals of Spring Boot

  • To develop a production-ready Spring application in an easier way.
  • To reduce the development time and run the application independently.
  • Avoids writing import statements.
  • Avoids defining more Annotation Configuration.

References

1.https://www.tutorialspoint.com/spring_boot/spring_boot_quick_start.htm

Nerd For Tech

From Confusion to Clarification

Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/. Don’t forget to check out Ask-NFT, a mentorship ecosystem we’ve started

Kasuni Madhushika

Written by

Software Engineering Undergraduate at Sri Lanka Institute Of Information Technology

Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/. Don’t forget to check out Ask-NFT, a mentorship ecosystem we’ve started

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store