Spring Boot – Disable Banner, Change Banner

One of the most often asked questions with Spring boot is how do i disable the banner or how can i change it

Lets look at that today.

Requisites

  • Java 1.8
  • Spring Boot 1.3.3
  • Maven 4
  • IntelliJ Idea/Eclipse

Disable Banner

The default banner is as below.

 

Soring boot banner 1a

 

There are few ways to do it, and the simplest is to call the setBannerMode() of Spring application

package com.atechref.spring;

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

/**
 * Spring boot app
 * @author APeter
 */
@SpringBootApplication
public class App {

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

When you start the application you see that the banner is not displayed anymore

Soring boot banner1

 

 

 

Change Banner

The simplest option is to add a “banner.txt” file in the class path with whatever text you would like to be displayed as the banner. Spring boot would pick it up automatically and display the contents of the file as the banner text.

We are going to use the same file as before, and remember to remove the line of code that disables the banner.

 

package com.atechref.spring;

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

/**
 * Spring boot app
 * @author APeter
 */
@SpringBootApplication
public class App {

    public static void main( String[] args ) {
        SpringApplication app = new SpringApplication(App.class);
        app.run(args);
    }
}

 

Contents of the banner.txt file is below

 

    _  _____         _     ____       __ 
   / \|_   _|__  ___| |__ |  _ \ ___ / _|
  / _ \ | |/ _ \/ __| '_ \| |_) / _ \ |_ 
 / ___ \| |  __/ (__| | | |  _ <  __/  _|
/_/   \_\_|\___|\___|_| |_|_| \_\___|_|

:: SpringBoot 1.3.3 :: www.ATechRef.com

 

When the app is started we get the following banner.

 

Soring boot banner 2

 

There are many websites that allows us to generate the banner text as strings. I used http://bigtext.org/ for this sample.

Leave a Reply

Your email address will not be published. Required fields are marked *