How to Disable Spring Boot Banner
When you start a spring boot application, the spring logo is printed on the console using ascii art. In spring boot terminology this is known as the boot startup banner. In default configuration, the startup banner is the first output printed on the console.
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.1.RELEASE)
When you are running your application in the production, you may want to turn off spring boot banner. There are a number of ways to disable spring boot banner.
Disable Spring Boot Banner Using banner-mode Property
You can disable spring boot banner using the spring.main.banner-mode property. This property can take 3 values,
- off - Turn off spring boot banner display
- console - Print banner using System.out on the console
- log - Print banner using the configured log file
So how do you set the value for spring.main.banner-mode property? Spring boot offers a number of options,
- Pass it as a parameter to the Java command,
- Set the property in the application.properties inside the resources folder of the spring boot project,
spring.main.banner-mode=off
- Set the property in the application.yaml if you are using YAML files,
spring:
main:banner-mode:"off"
Disable Spring Boot Banner Programmatically Using SpringApplication.setBannerMode
Spring boot also has an option to disable boot banner programmatically. You can use setBannerMode method of SpringApplication class. This requires minor changes to the main method of your spring boot application class as given below,
package com.example; import org.springframework.boot.Banner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class SimplespringappApplication { public static void main(String[] args) { SpringApplication app = new SpringApplication(SimplespringappApplication.class); app.setBannerMode(Banner.Mode.OFF); app.run(args); } }
It is also possible to supply your own banner by adding a file named banner.txt in the classpath.