By default, when you start a Spring Boot application, it displays an ASCII banner on the console. Here is how it looks like:

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

In this quick article, you'll learn how to customize the startup banner or turn it off completely 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 just 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 will 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 that you can 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

To turn off the startup banner completely when your Spring Boot application starts, just use any of the following methods.

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 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);
    }

}

Take a look at the official documentation to learn more about the startup banner in Spring Boot.

✌️ Like this article? Follow @attacomsian on Twitter. You can also follow me on LinkedIn and DEV. Subscribe to RSS Feed.

👋 If you enjoy reading my articles and want to support me to continue creating free tutorials, Buy me a coffee (cost $5) .

Need help to launch a new product? I am available for contract work. Hire me to accomplish your business goals with engineering and design.