Sunday, 1 September 2019

How to disable Spring logo banner in Spring Boot using command line option?

🚀 Level Up Your Java Skills!

Join the Ram N Java community for more expert Spring Boot tips and tricks.

SUBSCRIBE TO OUR CHANNEL

Revamp Your Spring Boot: How to Disable the Banner

Every time you launch a Spring Boot application, you're greeted by that familiar ASCII art "Spring" logo. While it's iconic, there are times—like in production environments or specialized console tools—where you might want a cleaner, faster startup experience. In this guide, we'll show you exactly how to remove it.

Why Disable the Spring Banner?

It's a small change, but it can make your logs look much cleaner. Beginners often find that removing unnecessary console output helps them focus on the actual application logs that matter during debugging.

Option 1: Using Application Properties

The simplest way to hide the banner is by adding a single line to your application.properties or application.yml file. This is the preferred method for most developers.

# Disable the Spring Boot startup banner
spring.main.banner-mode=off

Option 2: Programmatic Approach

If you want even more control, you can disable the banner directly in your main method using the SpringApplication builder. This is useful if you want to ensure the banner is off regardless of external property files.

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

Wrapping Up

Customizing your Spring Boot startup is one of the first steps in mastering the framework. Whether you're cleaning up logs or just want a "pro" feel to your console, disabling the banner is a quick win!


You Might Also Like:

No comments:

Post a Comment

Tutorials