springBoot定製自己的banner

2021-09-10 19:42:29 字數 1939 閱讀 2957

每當我們啟動springboot專案時,控制台上總會列印這樣的logo:

.    ____          _            __ _ _

/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \

( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \

\\/ ___)| |_)| | | | | || (_| | ) ) ) )

' |____| .__|_| |_|_| |_\__, | / / / /

*****====|_|**********====|___/=/_/_/_/

實際上是springboot在這個地方放置了乙個彩蛋,雖然沒有什麼實際的意義,但的確增加了不少樂趣;當我們不想要或者想要修改他時,springboot也給了我們隱藏和修改的空間。

**中隱藏:

public

static

void

main

(string[

] args)

我們也可以設定屬性,令其隱藏:

spring

:main

:banner-mode

: off

其實這個也是非常簡單的,我們只要在 resources 目錄下放置名為 banner.txt、banner.gif 、banner.jpg 或 banner.png 的檔案,spring boot 會自動載入,將其作為啟動時列印的 logo。

對於文字檔案,spring boot 會將其直接輸出。

對於影象檔案( banner.gif 、banner.jpg 或 banner.png ),spring boot 會將影象轉為 ascii 字元,然後輸出。

如果你使用的是 banner.txt 檔案中還可以使用變數來設定字型、顏色、版本號。

變數描述

manifest.mf 中定義的版本。如:1.0

manifest.mf 中定義的版本,並新增乙個 v 字首。如:v1.0

$spring boot 版本。如:2.1.1.release

$spring boot 版本,並新增乙個 v 字首。如:v2.1.1.release

$ (or $, $, $)

ansi 顏色、字型。更多細節,參考:ansipropertysource

manifest.mf 中定義的應用名

# banner 模式。有三種模式:console/log/off

# console 列印到控制台(通過 system.out)

# log - 列印到日誌中

# off - 關閉列印

spring.main.banner-mode = off

# banner 檔案編碼

spring.banner.charset = utf-8

# banner 文字檔案路徑

spring.banner.location = classpath:banner.txt

# banner 影象檔案路徑(可以選擇 png,jpg,gif 檔案)

spring.banner.image.location = classpath:banner.gif

used).

# 影象 banner 的寬度(字元數)

spring.banner.image.width = 76

# 影象 banner 的高度(字元數)

spring.banner.image.height =

# 影象 banner 的左邊界(字元數)

spring.banner.image.margin = 2

# 是否將影象轉為黑色控制台主題

spring.banner.image.invert = false

定製自己的CentOS

1 在 root 目錄下面 找到install.log 檔案並把在檔案中以 installing 開頭的行中的軟體包名剪下到另乙個檔案中,但是在該軟體中還有以數字開頭的軟體,且把該軟體包名也存到 如 建立乙個檔名為 package.txt 命令 touch package.txt 注用於存放 rpm...

SpringBoot定製錯誤頁面

1 有模板引擎的情況下,例如404錯誤,將會在thymeleaf的templates的error下尋找404.html,如果找不到再尋找4xx.html 所有4開頭的錯誤狀態碼如果找不到特定的html頁面將會指向4xx.html 頁面可以獲取到的資訊 timestamp 時間戳 status 狀態碼...

自己定製SPS的顏色

自己定製sps的顏色 通過昨天的學習,我知道可以使用css來定製sps站點的顏色,我以前也試過通過在管理介面上設定新的css路徑來更改sps站點的顏色,可以沒有成功。現在,我明白是因為自己放css檔案的路徑不對。我從原來的目錄下拷貝了乙個ows.css檔案,重新命名為ows zy.css,然後拷貝到...