Spring boot in some of the commonly used configuration!

Time:2021-6-15

This tutorial will introduce you to some common configurations in spring boot, such as custom banner, configuration log, turning off specific auto configuration, etc.

Custom banner

  When spring boot starts, there is a default boot pattern called banner.

  The default banner effect is as follows:

default

This banner comes with spring boot. If we think it's not good-looking, it can be changed. As a senior coder, how can we not customize our own banner?

  Create a new banner.txt

  We create a new banner.txt in Src / main / resources directory

  We just need to put the string we want to display in this file.



  Common banner setting properties

  ${AnsiColor.BRIGHT_ Red}: set the color of the output content in the console;

  ${application. Version}: used to obtain the version number in manifest.mf file;

  ${application. Formatted version}: formatted version information of ${application. Version} game;

  ${spring boot. Version}: the version number of spring boot;

  ${spring boot. Formatted version}: formatted version information of ${spring boot. Version}

Banner property

Other configurations of banner

  We can configure some basic properties of banner in application. Properties.

  We create one in Src / main / resources directory www.cungun.comapplication.properties Configuration file, in which the following configuration information can be added:

Other configurations of banner

These configuration information are mainly used to set the width, height and other attributes of the banner.

  Close banner

  If we don't want to show banner when we start the project, we can also close it. After all, it doesn't work. It's a typical trick.

  1. Code mode closing

  We can set the startup mode of banner in the application entry class, which is on by default and can be turned off

gameCode close

By calling the setbannermode () method, you can set the banner to print console, log, or not output off.

  2. YML file configuration

  We can also set the banner mode in the YML file. Note that in the YML file, off will be mapped to false, and brackets need to be added to off

yml

3. The configuration mode is closed

  In this way, you don't have to write code every time. You can find hide banner in the spring boot selection in edit configurations of each project, check it and close it!