SpringBoot banner

 

banner生成网址

http://patorjk.com/software/taag

 

配置

resources目录下新建banner.txt,SpringBoot默认会加载classpath下的banner.txt、banner.gifbanner.jpg, or banner.png 

 .----------------.  .----------------.  .----------------.  .-----------------. .----------------. 
| .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |
| |    _______   | || |  _________   | || |     ____     | || | ____  _____  | || |  _________   | |
| |   /  ___  |  | || | |  _   _  |  | || |   .'    `.   | || ||_   \|_   _| | || | |_   ___  |  | |
| |  |  (__ \_|  | || | |_/ | | \_|  | || |  /  .--.  \  | || |  |   \ | |   | || |   | |_  \_|  | |
| |   '.___`-.   | || |     | |      | || |  | |    | |  | || |  | |\ \| |   | || |   |  _|  _   | |
| |  |`\____) |  | || |    _| |_     | || |  \  `--'  /  | || | _| |_\   |_  | || |  _| |___/ |  | |
| |  |_______.'  | || |   |_____|    | || |   `.____.'   | || ||_____|\____| | || | |_________|  | |
| |              | || |              | || |              | || |              | || |              | |
| '--------------' || '--------------' || '--------------' || '--------------' || '--------------' |
 '----------------'  '----------------'  '----------------'  '----------------'  '----------------' 

 

启动项目

 .----------------.  .----------------.  .----------------.  .-----------------. .----------------. 
| .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |
| |    _______   | || |  _________   | || |     ____     | || | ____  _____  | || |  _________   | |
| |   /  ___  |  | || | |  _   _  |  | || |   .'    `.   | || ||_   \|_   _| | || | |_   ___  |  | |
| |  |  (__ \_|  | || | |_/ | | \_|  | || |  /  .--.  \  | || |  |   \ | |   | || |   | |_  \_|  | |
| |   '.___`-.   | || |     | |      | || |  | |    | |  | || |  | |\ \| |   | || |   |  _|  _   | |
| |  |`\____) |  | || |    _| |_     | || |  \  `--'  /  | || | _| |_\   |_  | || |  _| |___/ |  | |
| |  |_______.'  | || |   |_____|    | || |   `.____.'   | || ||_____|\____| | || | |_________|  | |
| |              | || |              | || |              | || |              | || |              | |
| '--------------' || '--------------' || '--------------' || '--------------' || '--------------' |
 '----------------'  '----------------'  '----------------'  '----------------'  '----------------' 
  
2021-01-06 17:43:42.983  INFO 788 --- [           main] com.stone.springboot.study.Application   : Starting Application on XXX with PID 788 (C:\tool\workspace\springboot-study\target\classes started by XXX in C:\tool\workspace\springboot-study)
2021-01-06 17:43:42.999  INFO 788 --- [           main] com.stone.springboot.study.Application   : No active profile set, falling back to default profiles: default
2021-01-06 17:43:45.159  INFO 788 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2021-01-06 17:43:45.195  INFO 788 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-01-06 17:43:45.195  INFO 788 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.41]
2021-01-06 17:43:45.460  INFO 788 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-01-06 17:43:45.460  INFO 788 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2352 ms
2021-01-06 17:43:45.960  INFO 788 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-01-06 17:43:46.284  INFO 788 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2021-01-06 17:43:46.332  INFO 788 --- [           main] com.stone.springboot.study.Application   : Started Application in 4.067 seconds (JVM running for 5.026)

 

 

Banner环境变量

Banner variables
VariableDescription

${application.version}

The version number of your application, as declared in MANIFEST.MF. For example, Implementation-Version: 1.0 is printed as 1.0.

${application.formatted-version}

The version number of your application, as declared in MANIFEST.MF and formatted for display (surrounded with brackets and prefixed with v). For example (v1.0).

${spring-boot.version}

The Spring Boot version that you are using. For example 2.3.7.RELEASE.

${spring-boot.formatted-version}

The Spring Boot version that you are using, formatted for display (surrounded with brackets and prefixed with v). For example (v2.3.7.RELEASE).

${Ansi.NAME} (or ${AnsiColor.NAME}${AnsiBackground.NAME}${AnsiStyle.NAME})

Where NAME is the name of an ANSI escape code. See AnsiPropertySource for details.

${application.title}

The title of your application, as declared in MANIFEST.MF. For example Implementation-Title: MyApp is printed as MyApp.

可以在txt文件中直接引用

banner也支持图片,当banner的文件名不是banner时,可通过配置识别到banner

application.yaml

spring:
  banner:
    image:
      location: 'xxx.jpg'

或者

spring:
  banner:
    location: 'xxx.txt'

 

关闭banner

方式一:启动时添加参数

--spring.main.banner-mode=off

方式二: 编码方式

package com.stone.springboot.study;

import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

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

 

posted @ 2021-01-07 14:47  硬石头  阅读(189)  评论(0)    收藏  举报