超個性修改SpringBoot項目的啟動banner的方法
如果我們使用過SpringBoot,那么就會對下面的圖案不陌生。Springboot 啟動的同時會打印下面的圖案,并帶有版本號。
查看SpringBoot官方文檔可以找到關(guān)于 banner 的描述
The banner that is printed on start up can be changed by adding a banner.txt file to your classpath or by setting the spring.banner.location property to the location of such a file. If the file has an encoding other than UTF-8, you can set spring.banner.charset. In addition to a text file, you can also add a banner.gif, banner.jpg, or banner.png image file to your classpath or set the spring.banner.image.location property. Images are converted into an ASCII art representation and printed above any text banner.
通過有道翻譯
可以通過向類路徑中添加一個banner.txt文件或設(shè)置spring.banner來更改在console上打印的banner。屬性指向此類文件的位置。如果文件的編碼不是UTF-8,那么可以設(shè)置spring.banner.charset。除了文本文件,還可以添加橫幅。將gif、banner.jpg或banner.png圖像文件保存到類路徑或設(shè)置spring.banner.image。位置屬性。圖像被轉(zhuǎn)換成ASCII藝術(shù)形式,并打印在任何文本橫幅上面。
在IDEA中,在SpringBoot配置文件中輸入spring.banner會出現(xiàn)下面提示,正對應(yīng)上面翻譯的內(nèi)容。
1、自定義banner
我們在類路徑下新建banner.txt文件,繪制下面圖案,下面地址就是繪制字符圖案。http://patorjk.com/software/taag/
SpringBoot項目啟動后如下,這樣我們就修改了banner。
我們暫時刪除banner.txt文件,將下面圖片放置在類路徑下,名稱為:banner.jpg。
然后在配置文件中配置如下內(nèi)容
啟動SpringBoot項目后,圖案如下所示,Springboot把圖片轉(zhuǎn)成 ASCII圖案。
如果我們不想在啟動時出現(xiàn)圖案,那么就需要修改SpringBoot啟動類的代碼
原代碼
public static void main(String[] args) { SpringApplication.run(SpringbootShiroApplication.class, args);}
修改后的代碼
public static void main(String[] args) { SpringApplication app = new SpringApplication(SpringbootShiroApplication.class); app.setBannerMode(Banner.Mode.OFF); app.run(args);}
這樣,SpringBoot啟動時就不會打印圖案了。當(dāng)然,還有其他的方式改變以及關(guān)閉啟動的圖案,如果大家有不一樣的方式,可以在下方評論來說明。
相關(guān)文章:
1. ASP刪除img標(biāo)簽的style屬性只保留src的正則函數(shù)2. 使用css實現(xiàn)全兼容tooltip提示框3. 一文帶你搞懂JavaScript中的進(jìn)制與進(jìn)制轉(zhuǎn)換4. 得到XML文檔大小的方法5. 詳解JS前端使用迭代器和生成器原理及示例6. javascript xml xsl取值及數(shù)據(jù)修改第1/2頁7. 詳解CSS偽元素的妙用單標(biāo)簽之美8. ASP編碼必備的8條原則9. 匹配模式 - XSL教程 - 410. 怎樣才能用js生成xmldom對象,并且在firefox中也實現(xiàn)xml數(shù)據(jù)島?