Preface
Everyone loves beauty. The indifferent programmers who work in the unix and linux command line environments may also think the command line is too monotonous, but they invented the way to use ansii characters to output various graphics on the command line. This is the banner under the command line, similar to the following
Some more introverted programmers even created dynamic banners. For example, in linux (CentOS) to execute the following command to install software sl
sudo yum install sl
After completion, enter a sl -a command on the command line and you will see a small train squirting with thick smoke, driving through the screen from right to left, and there are two little people cheering on it.
When SpringBoot is started, the following information will be printed on the command line:
This is the default banner of SpringBoot. This startup banner can be customized. The specific content comes from SpringBoot official documents
SpringBoot Text Banner Customization
The first way to customize SpringBoot is to edit a banner.txt file, then enter the content to be displayed in the banner, and finally store the file in the classpath path. Here we put it in the resource directory.
Generally, in order to display the effect, we will convert the content to be displayed into the form of ansii's artistic word. For example, if I want to display HELLO and GRACE in the banner, I will directly enter this text into the file. The display effect is not good. We need to convert it through a tool that converts text to ansii word art.
Copy the following ansii characters into the banner.txt file. Then start SpringBoot, start banner and become the following
In banner.txt, in addition to the ansii characters entered directly, the configuration of environment variables is also supported. For example, use ${spring-boot.version} to refer to the version of SpringBoot. The new banner.txt content becomes
The banner after startup is as follows
Refer to the official SpringBoot documentation for supported variables
SpringBoot Picture Banner Customization
If you think the startup banner of this text is not cool enough, we can also set the company's logo or product's logo image to the startup banner. Of course, it is not to display the image on the command line, but to parse the pixels of the image and then output it to the command line in the same way as ansii.
The banner of the picture supports gif, png, and jpeg formats. When using it, select the appropriate picture, then change the image name to banner, and then put it in resource and directory like the text banner.txt file.
For example, we will rename a file in the following jpeg format to banner.jpg file and put it in the resource directory
Then the banner started by the program becomes the following.
If there is a banner.txt file and a banner image file in the classpath, SpringBoot will first display the image banner, and then display the text banner.
Summarize
The above is the entire content of this article. I hope that the content of this article has certain reference value for everyone's study or work. If you have any questions, you can leave a message to communicate. Thank you for your support to Wulin.com.