How to change or disable the default banner in Spring Boot

When you start a Spring Boot application, it displays an ASCII banner on the console. Here is what it looks like:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.6.RELEASE)

In this short article, you'll learn how to customize the startup banner or turn it off in a Spring Boot application.

Customizing Banner

Spring Boot accepts ASCII text, PNG, GIF, and JPG files as a custom startup banner. To configure an ASCII banner, all you need to do is create a new ASCII banner using an online tool like Banner Generator and save it in src/main/resources/banner.txt file. Spring Boot will automatically pick it up and display it as a startup banner.

There is no specific format required for this file. You can put any ASCII character there. Here is an example banner.txt file that contains the following ASCII banner:

banner.txt

   ___  ______ ______   ___   _____  ____    __  ___   ____   ____   ___    _  __
  / _ |/_  __//_  __/  / _ | / ___/ / __ \  /  |/  /  / __/  /  _/  / _ |  / |/ /
 / __ | / /    / /    / __ |/ /__  / /_/ / / /|_/ /  _\ \   _/ /   / __ | /    /
/_/ |_|/_/    /_/    /_/ |_|\___/  \____/ /_/  /_/  /___/  /___/  /_/ |_|/_/|_/
${spring-boot.version} ----------------------------------------------------------

Now, if you run the Spring Boot application, it will output the following on the console:

   ___  ______ ______   ___   _____  ____    __  ___   ____   ____   ___    _  __
  / _ |/_  __//_  __/  / _ | / ___/ / __ \  /  |/  /  / __/  /  _/  / _ |  / |/ /
 / __ | / /    / /    / __ |/ /__  / /_/ / / /|_/ /  _\ \   _/ /   / __ | /    /
/_/ |_|/_/    /_/    /_/ |_|\___/  \____/ /_/  /_/  /___/  /___/  /_/ |_|/_/|_/
2.1.6.RELEASE -----------------------------------------------------------

You can even specify a custom location for the banner file by using the application.properties file:

spring.banner.location=classpath:static/banner.txt

Custom Font and Background Color

You can also specify the font and background color of the ASCII banner as shown below:

${AnsiBackground.WHITE}${AnsiColor.GREEN}
   ___  ______ ______   ___   _____  ____    __  ___   ____   ____   ___    _  __
  / _ |/_  __//_  __/  / _ | / ___/ / __ \  /  |/  /  / __/  /  _/  / _ |  / |/ /
 / __ | / /    / /    / __ |/ /__  / /_/ / / /|_/ /  _\ \   _/ /   / __ | /    /
/_/ |_|/_/    /_/    /_/ |_|\___/  \____/ /_/  /_/  /___/  /___/  /_/ |_|/_/|_/

In the example above, we have chosen a white background and green color for the ASCII banner text.

Using Banner Variables

Spring Boot provides several banner variables for use in your banner text file. Here is a list of available placeholders:

  • ${application.title} — The title of your application, as declared in MANIFEST.MF (if available)
  • ${spring-boot.version} — The Spring Boot version i.e. 2.1.6.RELEASE
  • ${spring-boot.formatted-version} — Formatted Spring Boot version i.e. (v2.2.0.BUILD-SNAPSHOT)
  • ${application.version} — The version number of your application, as declared in MANIFEST.MF, example 0.0.1.RELEASE
  • ${application.formatted-version} — The formatted version number of your application, as declared in MANIFEST.MF, example (v0.0.1)

The following example shows how you can use the above placeholders inside your ASCII banner file:

   ___  ______ ______   ___   _____  ____    __  ___   ____   ____   ___    _  __
  / _ |/_  __//_  __/  / _ | / ___/ / __ \  /  |/  /  / __/  /  _/  / _ |  / |/ /
 / __ | / /    / /    / __ |/ /__  / /_/ / / /|_/ /  _\ \   _/ /   / __ | /    /
/_/ |_|/_/    /_/    /_/ |_|\___/  \____/ /_/  /_/  /___/  /___/  /_/ |_|/_/|_/
Spring Boot ${spring-boot.version} ----------------------------------------------
${application.title} - ${application.formatted-version}

Programmatically Generated Banner

You can also generate the startup banner on the fly in your Spring Boot application:

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(Application.class);
        app.setBanner((environment, sourceClass, out) -> {
            out.println("======= Welcome to My Blog =======");
        });
        app.run(args);
    }
		
}

Disabling Banner

You can use the following methods to turn off the startup banner entirely when your Spring Boot application starts.

Add the following property in your application.properties file:

spring.main.banner-mode="off"

Or include the following to your application.yml file:

spring:
    main:
        banner-mode: "off"

Alternatively, you can also use the SpringApplication.setBannerMode() method in your main application class to disable the startup banner:

public class Application {

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

}

Read official documentation to learn more about the startup banner in Spring Boot.

✌️ Like this article? Follow me on Twitter and LinkedIn. You can also subscribe to RSS Feed.

You might also like...

Digital Ocean

The simplest cloud platform for developers & teams. Start with a $200 free credit.

Buy me a coffee ☕

If you enjoy reading my articles and want to help me out paying bills, please consider buying me a coffee ($5) or two ($10). I will be highly grateful to you ✌️

Enter the number of coffees below:

✨ Learn to build modern web applications using JavaScript and Spring Boot

I started this blog as a place to share everything I have learned in the last decade. I write about modern JavaScript, Node.js, Spring Boot, core Java, RESTful APIs, and all things web development.

The newsletter is sent every week and includes early access to clear, concise, and easy-to-follow tutorials, and other stuff I think you'd enjoy! No spam ever, unsubscribe at any time.