Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to modify the SpringBoot project to start banner

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "how to modify the SpringBoot project startup banner". The editor shows you the operation process through the actual case. The operation method is simple, fast and practical. I hope this "how to modify the SpringBoot project startup banner" article can help you solve the problem.

If we have used SpringBoot, then we will be familiar with the following patterns. When Springboot starts, it prints the following pattern with a version number.

Check the official SpringBoot documentation for a description of banner

The banner that is printed on start up can be changed by adding a banner.txt file to your classpath or by setting the spring.banner.location property to the location of such a file. If the file has an encoding other than UTF-8, you can set spring.banner.charset. In addition to a text file, 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.

Through Youdao Translation

You can change the banner printed on the console by adding a banner.txt file to the classpath or by setting the spring.banner. Property points to the location of such a file. If the encoding of the file is not UTF-8, you can set spring.banner.charset. In addition to text files, you can also add banners. Save the gif, banner.jpg, or banner.png image file to the classpath or set spring.banner.image. Location attribute. The image is converted into ASCII art form and printed on any text banner.

In IDEA, entering spring.banner in the SpringBoot configuration file will prompt you to correspond to the translation above.

1. Custom banner

We create a new banner.txt file under the classpath and draw the following pattern.

The SpringBoot project starts as follows, so we modify the banner.

We temporarily delete the banner.txt file and place the following image under the classpath named: banner.jpg.

Then configure the following in the configuration file

After starting the SpringBoot project, the pattern is shown below, and Springboot converts the picture into an ASCII pattern.

If we don't want the pattern to appear at startup, then we need to modify the code of the SpringBoot startup class

Original code

Public static void main (String [] args) {SpringApplication.run (SpringbootShiroApplication.class, args);}

Modified code

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

In this way, SpringBoot will not print the pattern when it starts.

This is the end of the content about "how to modify the SpringBoot project to start banner". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report