Today I would like to show you a feature of Spring that is not new, nor important, but it's just fun!
Usually, when launching your Spring Boot app, you would see in the logs something like that:
However, have you ever considered replacing the Spring banner in the logs with your custom banner? if so, follow this article!
To start, let's visit the website https://patorjk.com/ which will help us build our custom text. You can enter the text you want to see in your log and select the font out of tons of possible fonts. For example:
You can also easily clock the Test All button to see all possible options
Now, let's copy our text, and put it inside the application under the
/resources/banner.txt as follows:
Now, let's launch our app again:
As you can see, our banner was indeed replaced! Great job! :)
If you're using Spring Boot 2, you can also convert images into ASCII arthowever, this functionality is deprecated and was removed in Spring Boot 3.0.0 which was just released this week.
To do so, follow the steps:
Add your image to the resources directory. For this article we will use this logo:
Add to your
application.ymlfile the following configuration to locate your image:
spring: banner: image: location: sumup.png height: 20 # can be used to alter your banner size
- Ensure that you don't have any
banner.txtin your resource directory
Let's run our app again
As you can see, our new logo appeared like magic :)
In this short article, I have shown you how you can customize your Spring banner using text, or even images (if you're running on Spring boot
2.x.x) in a couple of minutes.
Oldest comments (0)