spring boot 自定義banner

spring boot的自定義banner

實現自定義banner功能的方式非常簡單,我們只需要在Spring Boot工程的/src/main/resources目錄下創建一個banner.txt文件,然後將ASCII字符畫複製進去,就能替換默認的banner了。比如採用了下面的banner.txt內容:

${AnsiColor.BRIGHT_GREEN}

##     ##    ###    ########  ########  ##    ##    ##    ## ######## ##      ##    ##    ## ########    ###    ########
##     ##   ## ##   ##     ## ##     ##  ##  ##     ###   ## ##       ##  ##  ##     ##  ##  ##         ## ##   ##     ##
##     ##  ##   ##  ##     ## ##     ##   ####      ####  ## ##       ##  ##  ##      ####   ##        ##   ##  ##     ##
######### ##     ## ########  ########     ##       ## ## ## ######   ##  ##  ##       ##    ######   ##     ## ########
##     ## ######### ##        ##           ##       ##  #### ##       ##  ##  ##       ##    ##       ######### ##   ##
##     ## ##     ## ##        ##           ##       ##   ### ##       ##  ##  ##       ##    ##       ##     ## ##    ##
##     ## ##     ## ##        ##           ##       ##    ## ########  ###  ###        ##    ######## ##     ## ##     ##

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

效果如下:


從上面的內容中可以看到,還使用了一些屬性設置:

  • ${AnsiColor.BRIGHT_RED}:設置控制檯中輸出內容的顏色
  • ${application.version}:用來獲取MANIFEST.MF文件中的版本號
  • ${application.formatted-version}:格式化後的${application.version}版本信息
  • ${spring-boot.version}:Spring Boot的版本號
  • ${spring-boot.formatted-version}:格式化後的${spring-boot.version}版本信息

生成工具

如果讓我們手工的來編輯這些字符畫,顯然是一件非常困難的差事。所以,我們可以藉助下面這些工具,輕鬆地根據文字或圖片來生成用於Banner輸出的字符畫。

永不宕機佛祖banner

最後,奉上程序猿必備Banner “永不宕機佛祖”,祝大家:“永不宕機、永無Bug”!

${AnsiColor.BRIGHT_YELLOW}
////////////////////////////////////////////////////////////////////
//                          _ooOoo_                               //
//                         o8888888o                              //
//                         88" . "88                              //
//                         (| ^_^ |)                              //
//                         O\  =  /O                              //
//                      ____/`---'\____                           //
//                    .'  \\|     |//  `.                         //
//                   /  \\|||  :  |||//  \                        //
//                  /  _||||| -:- |||||-  \                       //
//                  |   | \\\  -  /// |   |                       //
//                  | \_|  ''\---/''  |   |                       //
//                  \  .-\__  `-`  ___/-. /                       //
//                ___`. .'  /--.--\  `. . ___                     //
//              ."" '<  `.___\_<|>_/___.'  >'"".                  //
//            | | :  `- \`.;`\ _ /`;.`/ - ` : | |                 //
//            \  \ `-.   \_ __\ /__ _/   .-` /  /                 //
//      ========`-.____`-.___\_____/___.-`____.-'========         //
//                           `=---='                              //
//      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^        //
//            佛祖保佑       永不宕機     永無BUG                  //
////////////////////////////////////////////////////////////////////

效果圖:


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章