Install and Run Spring Boot Linux Service Guide

Let’s learn how to install a spring boot as a linux service. Requirements You will need, Basics of running a spring boot application Understanding linux services and file system. 15 minutes of your time. Make the jar an executable Spring boot applications can be started using the command java -jar hello-world.jar. We have seen this behaviour in the posts How…

Spring IOC Container

Traditionally, the flow of business logic depends on the statically defined objects and their dependents. This approach creates tightly coupled applications that are hard to extend or modify. But with IOC containers, the business logic depends on the object graph built by an IOC container. So what is an IOC Container? Inversion Of Control(IoC) is…

@SpringBootApplication annotation – How it works

Every spring boot application has the @SpringBootApplication annotation on its main class. On contrary to popular belief, it is not just there to inform that the application is a spring boot application. Let’s take a deep dive into what this annotation is and how it works with some examples. Introduction The @SpringBootApplication annotation is there…

JAR to WAR: Deploy Spring Boot on App Servers like Tomcat

In this post, We will learn about converting Spring Boot JAR to WAR file. We know that Spring Boot produces a fat JAR That helps You to start the app by running java -jar <your jar file>. We can deploy these JARs with ease. But in unavoidable situations, you may need a WAR file. Each application runs on a separate port….

Shell Scripts to start and Stop Spring Boot Applications.

In this post, We will learn about start and stop shell scripts to run Spring Boot applications. Spring boot applications are easier to build and run. However, there is one small problem. Most of the developers still struggle when it comes to running, stopping, and starting the application in production servers. The traditional applications were deployed…

Spring Boot Starters

Spring Boot Starters add or change the behavior of an application. Starters do this through opinionated defaults and auto-configurations. Background In a traditional web application, The developers will have to do the following stuff. Write a spring-context.xml to define the beans required. Write definitions for your database configuration. Define MVC configuration and their mappings/filters/etc. Create a web.xml to…

Spring Boot Hello World Tutorial

Let’s build a Hello World web application using Spring Boot. We will go through step by step to learn how to do this. Generate A Spring Boot Project There are multiple ways to setup a Spring Boot application. However, the easiest way to do it via Spring Initializer. Open the Spring Initializer page and add…

N+1 Selects problem in Hibernate and How to Avoid it

Let us talk about the infamous N+1 selects problem in hibernate entities and how to solve it with some examples. You may have also heard it as an N+1 queries problem in some places. What is the N+1 selects problem? The N+1 selects problem is a performance anti-pattern where an application makes N+1 small queries to the…

Accessing Command-line Arguments in Spring Boot

Let’s learn how to read command-line arguments of a Spring Boot Application. Like any other java program, Spring Boot can take program parameters of application parameters on startup. But spring boot goes extra-mile to argument parsing. Lets get into the details. CommandLineRunner and ApplicationRunner These two interfaces are similar in nature and help you access…

Paginating RESTful API responses in Spring MVC

Pagination lets you split large RESTful API responses from Spring MVC into smaller chunks called pages. In this post, let us see how to use Spring MVC and Spring JPA to paginate a JSON response from a spring boot application. Pagination and Sorting in Spring MVC As we have seen earlier, we can implement pagination…