Personalize Your Application Startup with a Custom Banner

ayshriv

Ayush Shrivastava

Posted on September 19, 2024

Personalize Your Application Startup with a Custom Banner

In this blog post, I'll show you how to customize the banner that appears when you start your Spring Boot application. If you want to add a fun message, showcase your brand, or even display details like the app version, this step-by-step guide is for you. We'll cover how to change the colors and styles of your banner to make it stand out and how to include dynamic information that updates each time you run your app. It’s a great way to give your Spring Boot project a personal touch!

Introduction to Spring Boot Banners

When you start a Spring Boot application, you'll notice the Spring logo and some default text printed in the console. This is called the "banner," and it serves as a friendly greeting for your application. The banner provides a quick visual cue that your app is up and running. While the default banner is nice, you can easily customize it to add your own touch or branding. Whether you want to display your company logo, a fun message, or important information about your app, customizing the banner is a simple way to make your application feel more personal.

Why Customize Your Spring Boot Banner?

Customizing your Spring Boot banner has several benefits. First, it helps with branding by allowing you to add your company logo or a unique message, making your application easily recognizable. Second, it adds personalization, reflecting your style or project theme and engaging users. You can also use the banner to communicate important information, like the application version or whether it’s in development or production. A well-designed banner gives your application a polished look, making it feel more professional. Lastly, adding fun elements or jokes can make the startup process more enjoyable for everyone involved.

Mode of Spring-boot banners

There are three types of modes of spring-boot banner

  • Off - no banner is printing on the console
  • Log - banner is printing on log file
  • Console - It is a default mode of the application

We can set banner mode using below property inapplication.properties file

spring.main.banner-mode=off
Enter fullscreen mode Exit fullscreen mode

How to Create a Custom Banner File

To create a custom banner for your Spring Boot application, you can use an online tool to generate cool ASCII art. One of the most popular options is patorjk.com. This tool lets you type your text and choose from a variety of fonts and styles to generate an ASCII banner. Once you're happy with your design, simply copy the generated text and paste it into your banner.txt file in your Spring Boot project.

ASCII art

Project Structure

In this guide, we’ll walk you through the process of customizing the default banner in your Spring Boot application. Whether you want to add a personalized message, company branding, or dynamic information like version details, this step-by-step tutorial will help you create a unique startup banner. You’ll also learn how to apply custom colors and styles using ANSI codes, and explore ways to display dynamic content to make your banner more informative. Perfect for developers looking to add a personal touch to their Spring Boot projects!

When you run a Spring Boot application in its default mode, the Spring logo is automatically printed in the console during startup. This default banner is simple and includes the Spring logo along with some version details. If you don't customize or disable it, this logo will always appear when your application starts.

The image shows a console window displaying the startup of a Spring Boot application with a customized ASCII art banner. The banner includes a large, stylized logo or text in a graffiti-like font. Beneath the banner, there’s additional information such as the application version, active profiles (e.g., development or production), and other system details like the JVM version. The background is dark with the ASCII art banner in bright colors, creating a sharp contrast. This visual highlights how a custom banner enhances the identity of the Spring Boot application during startup.

Disabling the Spring Boot Banner

you can turn it off completely if you prefer a clean console output.
To disable the default Spring Boot banner, simply add the following line to your application.properties file:

The image shows a console window displaying the startup of a Spring Boot application with a customized ASCII art banner. The banner includes a large, stylized logo or text in a graffiti-like font. Beneath the banner, there’s additional information such as the application version, active profiles (e.g., development or production), and other system details like the JVM version. The background is dark with the ASCII art banner in bright colors, creating a sharp contrast. This visual highlights how a custom banner enhances the identity of the Spring Boot application during startup.

spring.main.banner-mode=off

Enter fullscreen mode Exit fullscreen mode

clean console output we get

The image shows a console window displaying the startup of a Spring Boot application with a customized ASCII art banner. The banner includes a large, stylized logo or text in a graffiti-like font. Beneath the banner, there’s additional information such as the application version, active profiles (e.g., development or production), and other system details like the JVM version. The background is dark with the ASCII art banner in bright colors, creating a sharp contrast. This visual highlights how a custom banner enhances the identity of the Spring Boot application during startup.

Incorporating Dynamic Information in the Banner

To customize the banner in Spring Boot, you can create a banner.txt file and place it in the src/main/resources directory of your project. The content of this file will be displayed when your application starts. You can add custom ASCII art, text, or any message you'd like.

For example, you can use a tool like patorjk.com to generate cool ASCII text. Just copy the generated text and paste it into the banner.txt file.

The image shows a console window displaying the startup of a Spring Boot application with a customized ASCII art banner. The banner includes a large, stylized logo or text in a graffiti-like font. Beneath the banner, there’s additional information such as the application version, active profiles (e.g., development or production), and other system details like the JVM version. The background is dark with the ASCII art banner in bright colors, creating a sharp contrast. This visual highlights how a custom banner enhances the identity of the Spring Boot application during startup.

Testing Your Customized Banner

you can easily modify this banner by creating your own banner.txt file

The image shows a console window displaying the startup of a Spring Boot application with a customized ASCII art banner. The banner includes a large, stylized logo or text in a graffiti-like font. Beneath the banner, there’s additional information such as the application version, active profiles (e.g., development or production), and other system details like the JVM version. The background is dark with the ASCII art banner in bright colors, creating a sharp contrast. This visual highlights how a custom banner enhances the identity of the Spring Boot application during startup.

Conclusion: Enhance Your Application’s Identity

In conclusion, customizing the Spring Boot banner is a simple yet effective way to enhance your application’s identity. By adding your own logo, personalized message, or even dynamic information like version numbers or environment details, you can make your application more engaging and professional. This not only improves the visual appeal but also provides useful insights at startup. Tools like patorjk.com make it easy to create custom banners. Whether you want to add branding or just have fun, customizing the banner can make your Spring Boot application truly stand out.

💖 💪 🙅 🚩
ayshriv
Ayush Shrivastava

Posted on September 19, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related