Java

Spring Boot Lifecycle Hooks

A brief intro into Spring Lifecycle hooks

Chirag S P
In this article we will talking about Spring Boot life cycle hooks and where we would use them. We will covering below topics, What is a Bean in Spring Boot ? Its an object that is created and managed by Spring IOC. Basically any object managed by ApplicationContext class of Spring is called a Bean. What is Bean Life Cycle ? The spring Bean life cycle is as follows,

Migrating Spring to Spring Boot

How to migrate from Spring to Spring Boot.

Chirag S P
As more and more applications move towards platform-as-a-service(PAAS), many companies are looking to migrate from Spring MVC to Spring Boot. Migrating from Spring MVC to Spring Boot involves quite a few changes affecting the entire application. In this article I will explain my experience on migrating Spring MVC to Spring Boot in my current company and the issues I faced doing the same. 1. POM Changes First thing to do, is the POM changes.

How to setup Logging in Spring Boot

Implement Logback in Spring Boot

Chirag S P
Spring Boot comes with build-in logging functionality and its very easy to integrate. Logback Spring Boot uses logback logging framework. Logback in an upgrade of log4j framework. It comes bundled with spring boot starter packs. For example if we using spring web service, then logback comes bundled with it. <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web-services<actifactId> </dependency> Implementation To use logging in a Java class use below code Logger logger = LoggerFactory.getLogger(getClass()); logger.error("This is an error"); That’s it !

How to set Java options in Tomcat

Setup Java options using GUI and command line

Chirag S P
When running tomcat we might need to setup Java options in it . In this article we will go through on how to setup JVM (i.e Java Options) options in Tomcat 8-8.5 in windows. In windows we can setup Java options using one of the below methods Using Tomcat.exe gui Go to Tomcat folder→bin and open Tomcatw.exe. This will open the GUI. Switch to ‘Java’ tab. Put in Java Options in Java tab:

How to Fix CORS Error in Spring boot JWT Security

Solution for CORS error in Sprint Boot Security deployed in Heroku

Chirag S P
CORS error is one of the most annoying errors which one can encounter while developing web applications. CORS is a mechanism that allows Server to indicate to Browser to allow connections from origins other than its own. Browser will send a pre-flight connection request(an Options request) to server to check if server will allow the request. If server allows the request from this origin it will respond with Access-Control-Allow-Origin. I encountered this error while developing an Angular application.

How to setup Pagination in Spring Boot and Hibernate

Implement pagination in APIs

Chirag S P
When dealing with large amounts of data in a front-end application, we often need to break it down to smaller chucks so as to not overwhelm the user. Hence in front-end application we display large chucks of data as pages. Using this technique, we can request only required data for displaying only a single page at a time. To achieve this, we require pagination in API requests Spring boot makes it easy to setup pagination with hibernate.

Hide Spring boot parameters and endpoints in Swagger

How to hide parameters and endpoints from swagger

Chirag S P
When we setup swagger documentation, a need might arise to hide endpoints or parameters. We might have a scenario wherein an endpoint is still being developed and we don’t want it being used by the end user, or some special parameters might be used like Pricipal or Http related parameters and this need not appear in Swagger documentation. How to hide parameters in Swagger First lets look into how to hide parameters in Swagger.

Deploy Spring boot Jar Docker to Heroku using two different ways

A short tuts on deploying spring boot jar docker to heroku

Chirag S P
Imagine you and your buddy are developing a Spring boot Rest application using Java 11. To make it run consistently in yours and your buddy’s machine you decide to setup Sprint boot jar in Docker. Now the docker setup is done, you want to release it to world and announce it in Product hunt. Out of many cloud provider like AWS, Google cloud; Heroku is the most beginner friendly, whilst offering advanced features which can be scaled for a production level application.

How to deploy Spring Boot War in Docker

Setup Spring Boot Rest API war in Docker

Chirag S P
So, you’ve developed your Spring Boot rest API and generated the war. You’ve even managed to successfully deploy it in a tomcat server. Now you’re thinking of containerizing your application. This blog will guide you in deploying spring boot war to docker image. Docker Intro Docker is a platform-as-a-service tool (PAAS) that provides virtualization on OS level called containers. It uses some common OS libraries but overall each container is isolated from one another.

Multi-tenancy using Spring Boot and Hibernate

Implement Multi-tenancy using Spring boot

Chirag S P
In modern Sass applications, a single application can be used by multiple companies(tenant). There are three ways with which one can divide an application by, Single schema and a single DB instance Separate Schema for each company but single DB instance Different DB instances for each Company In this article, we will be looking into the second method , i.e Separate Schema for each tenant or company using Spring Boot.