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.