Replace Spring banner in a Spring Boot application
This post will discuss how to replace the Spring banner in a Spring Boot application.
When your application starts, you see something similar to the following output:
/\\ / ___’_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | ‘_ | ‘_| | ‘_ \/ _. | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
‘ |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.1.RELEASE)
Spring Boot allows us to replace the above banner with our custom banner or image.
1. The banner that is printed on startup can be changed by adding a banner.txt
file to your classpath or setting the spring.banner.location
property to the location of such a file. Inside your banner.txt
file, you can also use any of the following placeholders listed here.
Several ‘Text to ASCII’ Art Generator is available online for free (see this or this).
2. You can also add a banner.gif
, banner.jpg
, or banner.png
image file to your classpath or set the spring.banner.image.location
property. Images are converted into an ASCII art representation and printed above any text banner.
3. We can even use the SpringApplication.setBanner(…)
method to generate a banner programmatically. We can do this by implementing the org.springframework.boot.Banner
interface and implement your own printBanner()
method.
That’s all about replacing the Spring banner in a Spring Boot application.
Thanks for reading.
To share your code in the comments, please use our online compiler that supports C, C++, Java, Python, JavaScript, C#, PHP, and many more popular programming languages.
Like us? Refer us to your friends and support our growth. Happy coding :)