實現(xiàn)的方式非常簡單,我們只需要在Spring Boot工程的 /src/main/resources
目錄下創(chuàng)建一個banner.txt
文件,然后將ASCII字符畫復(fù)制進(jìn)去,就能替換默認(rèn)的banner了。比如上圖中的輸出,就采用了下面的banner.txt
內(nèi)容:
${AnsiColor.BRIGHT_GREEN}
## ## ### ######## ######## ## ## ## ## ######## ## ## ## ## ######## ### ########
## ## ## ## ## ## ## ## ## ## ### ## ## ## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## #### #### ## ## ## ## ## #### ## ## ## ## ##
######### ## ## ######## ######## ## ## ## ## ###### ## ## ## ## ###### ## ## ########
## ## ######### ## ## ## ## #### ## ## ## ## ## ## ######### ## ##
## ## ## ## ## ## ## ## ### ## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ######## ### ### ## ######## ## ## ## ##
${AnsiColor.BRIGHT_RED}
Application Version: ${application.version}${application.formatted-version}
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
從上面的內(nèi)容中可以看到,還使用了一些屬性設(shè)置:
${AnsiColor.BRIGHT_RED}
:設(shè)置控制臺中輸出內(nèi)容的顏色${application.version}
:用來獲取MANIFEST.MF
文件中的版本號${application.formatted-version}
:格式化后的${application.version}
版本信息${spring-boot.version}
:Spring Boot的版本號${spring-boot.formatted-version}
:格式化后的${spring-boot.version}
版本信息
#生成工具
如果讓我們手工的來編輯這些字符畫,顯然是一件非常困難的差事。所以,我們可以借助下面這些工具,輕松地根據(jù)文字或圖片來生成用于Banner輸出的字符畫。
- http://patorjk.com/software/taag
- http://www.network-science.de/ascii/
- http://www.degraeve.com/img2txt.php