Spring Boot 默认打印的 banner
要想修改它,需要在 resources 目录下添加一个 banner.txt 文件
banner.txt 文件语法
${application.version} MANIFEST.MF文件中的版本号(目前无法获取到,应该是spring的一个BUG)
${application.formatted-version} 上面的的版本号前面加v后上括号
${spring-boot.version} springboot的版本号
${spring-boot.formatted-version} 上面的的版本号前面加v后上括号
spring-boot.version 是在 build.gralde 中定义的
buildscript {
ext {
springBootVersion = '2.1.1.RELEASE'
}
}
AnsiColor 支持的颜色可以在官网查到 https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/ansi/AnsiColor.html
- BLACK
- BLUE
- BRIGHT_BLACK
- BRIGHT_BLUE
- BRIGHT_CYAN
- BRIGHT_GREEN
- BRIGHT_MAGENTA
- BRIGHT_RED
- BRIGHT_WHITE
- BRIGHT_YELLOW
- CYAN
- DEFAULT
- GREEN
- MAGENTA
- RED
- WHITE
- YELLOW
Spring Boot支持高亮输出(即 带颜色的输出),但默认是关闭的,需要在 application.properties 中添加如下内容开启:
spring.output.ansi.enabled=ALWAYS
如果想关闭 Banner 的打印,就修改 YourProjectApplication.java,来禁用输出 Banner
public static void main(String[] args) {
//SpringApplication.run(DemoApplication.class, args);
SpringApplication springApplication = new SpringApplication(DemoApplication.class);
springApplication.setBannerMode(Banner.Mode.OFF);
springApplication.run(args);
}
ASCII 字符画生成工具
- 根据文字生成字符画
http://patorjk.com/software/taag
http://www.network-science.de/ascii/
- 根据图片生成字符画
http://www.degraeve.com/img2txt.php
(由于解析的图片中的宽高不一致,因此放到banner里面就像被压缩了一样,不好看)
banner.txt 实践
${AnsiColor.CYAN}
______
| ___ \
| |_/ / __ _ _ __ _ __ ___ _ __
| ___ \/ _` | '_ \| '_ \ / _ \ '__|
| |_/ / (_| | | | | | | | __/ |
\____/ \__,_|_| |_|_| |_|\___|_|
${AnsiColor.MAGENTA}
:: Spring Boot ::${application.version} ${spring-boot.formatted-version}
${AnsiColor.BRIGHT_YELLOW} Application Version: ${application.version}${application.formatted-version}
${AnsiColor.BRIGHT_BLUE} Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
网上找的一张佛陀的好运图。。。
// _oooOooo_ //
// o888888888o //
// 88" . "88 //
// (| ^_^ |) //
// O\ = /O //
// ____/`-----'\____ //
// .' \\| |// `. //
// / \\||| : |||// \ //
// / _||||| -:- |||||- \ //
// | | \\\ - /// | | //
// | \_| ''\---/'' | | //
// \ .-\__ `-` ___/-. / //
// ___`. .' /--.--\ `. . ___ //
// ."" '< `.___\_<|>_/___.' >'"". //
// | | : `- \`.;`\ _ /`;.`/ - ` : | | //
// \ \ `-. \_ __\ /__ _/ .-` / / //
// ========`-.____`-.___\_____/___.-`____.-'======== //
// `=---=' //
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
// 佛祖保佑 永不宕机 永无BUG //