Home > Spring > Spring Boot

Spring Boot

Set globally multiple header parameters in Swagger

swagger

In this article, we will learn how to set multiple header parameters globally in a Spring Boot application. Why do we need it? There are cases where we want the client to send multiple header parameters along with the one auth token, these parameters may be useful to validate the token or may be required along with the token to ... Read More »

CVE-2021-44228 Spring Boot and Log4j2 Vulnerability

spring

What is CVE-2021-44228? CVE-2021-44228 is a vulnerability impacting all the applications written in Java and using the component Apache Log4j2 for logging. This vulnerability allows the unauthenticated remote code execution using the JNDI Lookup. Log4j2 is widely used directly or through dependencies in almost every Java application. These application includes almost all the enterprise level application and almost all the ... Read More »

Enable the access logs in Spring Boot for embedded tomcat server

spring

Access logs contains the information about the request received and response sent to the client. It contains all the important data which are required to analyze the type of request coming to the application. Below are the steps which is required to configure the tomcat access logs for the Spring Boot application. Settings in application.properties file These are the common ... Read More »

Create a custom favicon in Spring Boot application

spring

In this article, we will learn how to configure custom favicon in the spring boot application. Favicon is the iconic representation of any website. It is placed in the address bar of any web browser. Spring boot provides option to create custom favicon for your website. First create a favicon for your website, place it in the resources directory of ... Read More »

Configure Logback in Spring-Boot Application for Logging

spring

In this article, we will learn how to configure logback in the spring boot application for logging and how to configure Logback with specifications including console and file output separately, and here we will also learn to use the rolling file policy to avoid generating large size log files and after a certain threshold size limit it will be back ... Read More »

Configure Spring RestTemplate with OkHttp3 in Spring Boot Application

spring

Okhttp3 is a popular HTTP client implementation for Java and we can easily embed it in our Spring Boot RestTemplate abstraction. Below is the Bean definition which binds the instance of Okhttp3 client with RestTemplate. Now to integrate in our implementation class we just need to autowire the Resttemplate to use this customized Okhttp3 based resttemplate. How to use RestTemplate ... Read More »

Configure Spring RestTemplate with HttpClient in the Spring Boot Application

spring

In this post we will learn how to configure Spring RestTemplate with HttpClient in the Spring boot Applications. This example supports both HTTP and HTTPS. It Uses a connection-pool configurations to re-use connections and save overhead of creating connections. It has configurable request and socket timeouts, keep-alive strategy and also close idle connection strategy to monitor inactive connections and clean ... Read More »

Autowiring Components from external jars in Spring Boot Project

spring

In an Spring Boot project, sometimes we have to autowire components which are available in another jar or in another module which is added as a jar in the main module of the project. Considering the use case of my spring boot application, I created my Spring Boot project, using maven modules. One of the modules was called daolayer, one ... Read More »

Hide an End-points from Swagger Documentation in Spring Boot REST API

swagger

In this article, we will learn how to hide any end-points or entire controller for swagger documentation. While integrating Swagger with our Spring Boot REST API application we often require to hide some of the endpoints from the end-user, sometimes an entire Class of implementation is to be hidden from the end-user because these are some private types of endpoints. ... Read More »