Home > Java > javaTutorial > How to modify the SpringBoot project startup banner

How to modify the SpringBoot project startup banner

WBOY
Release: 2023-05-11 18:49:14
forward
2036 people have browsed it

If we have used SpringBoot, then the following pattern will be familiar to us. When Springboot starts, the following pattern will be printed with the version number.

How to modify the SpringBoot project startup banner

View the official SpringBoot documentation to find a description of the 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.

Translated by Youdao

Can be changed on the console by adding a banner.txt file to the classpath or setting spring.banner Printed banner. Property points to the location of such a file. If the encoding of the file is not UTF-8, then spring.banner.charset can be set. In addition to text files, banners can also be added. Save a gif, banner.jpg or banner.png image file to the classpath or set spring.banner.image. location attribute. The image is converted to ASCII art form and printed on top of any text banner.

In IDEA, when you enter spring.banner in the SpringBoot configuration file, the following prompt will appear, which corresponds to the translated content above.

How to modify the SpringBoot project startup banner

1. Custom banner

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

How to modify the SpringBoot project startup banner

After the SpringBoot project is started, as follows, we have modified the banner.

How to modify the SpringBoot project startup banner

We temporarily delete the banner.txt file and place the following image on the classpath with the name: banner.jpg.

How to modify the SpringBoot project startup banner

Then configure the following content in the configuration file

How to modify the SpringBoot project startup banner

After starting the SpringBoot project, the pattern As shown below, Springboot converts the image into ASCII pattern.

How to modify the SpringBoot project startup banner

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);
}
Copy after login

Modified code

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

In this way, the pattern will not be printed when SpringBoot starts.

The above is the detailed content of How to modify the SpringBoot project startup banner. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template