這篇文章主要介紹“怎么修改SpringBoot項(xiàng)目啟動(dòng)banner”的相關(guān)知識(shí),小編通過實(shí)際案例向大家展示操作過程,操作方法簡單快捷,實(shí)用性強(qiáng),希望這篇“怎么修改SpringBoot項(xiàng)目啟動(dòng)banner”文章能幫助大家解決問題。
創(chuàng)新互聯(lián)主營東至網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,成都app軟件開發(fā)公司,東至h5小程序制作搭建,東至網(wǎng)站營銷推廣歡迎東至等地區(qū)企業(yè)咨詢如果我們使用過SpringBoot,那么就會(huì)對(duì)下面的圖案不陌生。Springboot 啟動(dòng)的同時(shí)會(huì)打印下面的圖案,并帶有版本號(hào)。

查看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.
通過有道翻譯
可以通過向類路徑中添加一個(gè)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會(huì)出現(xiàn)下面提示,正對(duì)應(yīng)上面翻譯的內(nèi)容。

1、自定義banner
我們?cè)陬惵窂较滦陆╞anner.txt文件,繪制下面圖案。

SpringBoot項(xiàng)目啟動(dòng)后如下,這樣我們就修改了banner。

我們暫時(shí)刪除banner.txt文件,將下面圖片放置在類路徑下,名稱為:banner.jpg。

然后在配置文件中配置如下內(nèi)容

啟動(dòng)SpringBoot項(xiàng)目后,圖案如下所示,Springboot把圖片轉(zhuǎn)成 ASCII圖案。

如果我們不想在啟動(dòng)時(shí)出現(xiàn)圖案,那么就需要修改SpringBoot啟動(dòng)類的代碼
原代碼
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)時(shí)就不會(huì)打印圖案了。
關(guān)于“怎么修改SpringBoot項(xiàng)目啟動(dòng)banner”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí),可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,小編每天都會(huì)為大家更新不同的知識(shí)點(diǎn)。
文章名稱:怎么修改SpringBoot項(xiàng)目啟動(dòng)banner-創(chuàng)新互聯(lián)
文章路徑:http://chinadenli.net/article8/cdocop.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、網(wǎng)站維護(hù)、做網(wǎng)站、網(wǎng)頁設(shè)計(jì)公司、網(wǎng)站營銷、軟件開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容