Custom Spring Boot Startup Banner

Arvind Kumar
3 min readMar 6, 2020

If you are creating an application with spring boot framework, then you ARE definitely aware of the spring boot banner —

spring-boot default banner

Did you ever think about customizing it, like —

  1. Disable it or
  2. Use your own banner which shows the name of your application or company name

We can do it easily. First, let’s talk about disabling it —

How to disable default spring boot banner

There are two ways —

  1. Using configuration value in the application.properties/application.yaml

In the above screenshot, you can see after adding the configuration value, there is no banner appearing in the application startup log.

application.yaml file content —

spring:
main:
banner-mode: OFF

application.properties file content —

spring.main.banner-mode=OFF

yaml and properties files are the two ways, we can pass configuration to spring boot application. In case you want to know more detail about it take a look here — https://youtu.be/Vonxkq5ELhE

2. Programatically in the Main class file

In the above screenshot, you can see after adding the few lines under Main class, we can set the banner mode OFF. Here is the complete code —

package com.gl.helloworld;

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

@SpringBootApplication
public class HelloworldApplication {

public static void main(String[] args) {
SpringApplication app = new SpringApplication(HelloworldApplication.class);
app.setBannerMode(Banner.Mode.OFF);
app.run(args);
}

}

Now moving ahead — What if we want to add our own custom banner

How to Add custom spring boot starter banner

First things first, how to create the banner —

  1. Go to the link http://patorjk.com/software/taag/#p=display&h=3&f=Doom&t=Green%20Learner
  2. Add the text in the text box, you will get the banner in text format
  3. copy the text and save it in file — banner.txt

Now we have the banner file ready

  1. Come to spring boot application and add this banner.txt file under main/resources/
  2. Add the configuration details under application.yaml and start the application

you can place the banner.txt file anywhere in the application then you have to change configuration detail accordingly.

Apart from text banners, we can also add the image as banners but images take more time in processing which affects the startup time so not advisable but you can do if you want to. See spring boot documentation for more details about this.

If you would like to do more customization around this here is the spring boot official documentation about same — https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-banner

So that’s all about the spring boot custom banners.

Hope you learned something.

All the source code above can be found on GitHub repository — Green Learner

If you wish to learn more about spring boot and latest trends in software development check out my youtube channel — Green Learner.

Cheers!!

Happy Coding!!

--

--