Spring Boot Custom Banner Tutorial

When we start SpringBoot, the console will print SpringBoot Logo and version information. Sometimes we need to get hold of their own personality text pictures. Spring Boot provides us with a custom interface.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.8.RELEASE)

Custom banner is actually very simple, as long as new in the resource (src / main / resources) directory banner.txt our custom content written this banner.txt on it, see the following code demonstrates specific.

The project github source code download

1 New Spring Boot Maven example projects

Note: IDEA is a development tool for

  1. File> New> Project, select the figure below Spring Initializrand then click [Next] Next
  2. Fill GroupId(package name), Artifact(project name) can be. Click Next
    groupId = com.fishpro
    artifactId = Banner
  3. The choice depends Spring Web Starterfront tick.
  4. Project name is set spring-boot-study-banner.

2 Writing Custom Banner

2.1 First create a Banner.txt

First create a Banner.txt, where it can go automatically put forward, please Baidu or Google itself.

 ____  __  ____  _  _  ____  ____   __  
(  __)(  )/ ___)/ )( \(  _ \(  _ \ /  \ 
 ) _)  )( \___ \) __ ( ) __/ )   /(  O )
(__)  (__)(____/\_)(_/(__)  (__\_) \__/ 

Here are some tools online collection

Add color to the terminal and the text effects

2.2 custom color version, etc.

Set in the banner.txt

 ____  __  ____  _  _  ____  ____   __
(  __)(  )/ ___)/ )( \(  _ \(  _ \ /  \
 ) _)  )( \___ \) __ ( ) __/ )   /(  O )
(__)  (__)(____/\_)(_/(__)  (__\_) \__/

${AnsiColor.BRIGHT_RED}
Application Version: ${application.version}${application.formatted-version}
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}

Parameter Description:

  • $ {AnsiColor.BRIGHT_RED}: color output setting console content, can be customized with specific reference org.springframework.boot.ansi.AnsiColor
  • $ {Application.version}: to get the version number MANIFEST.MF file, which is why you want to specify in Application.java in SpringVersion.class
  • {Application.formatted-version}: {application.version} formatted version information
  • $ {Spring-boot.version}: Spring Boot version number
  • {Spring-boot.formatted-version}: formatted {spring-boot.version} version information

2.3 Test

Run the program again, then print from the console on our custom picture

Guess you like

Origin www.cnblogs.com/fishpro/p/spring-boot-study-banner.html