網頁

2021/6/8

Spring Boot 關閉啟動時的Spring logo標題 disable console spring logo banner

Spring Boot專案在啟動時都會在console印出Spring ANSI圖形,關閉方法如下。


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.x.x.RELEASE)

在配置檔application.properties設定spring.main.banner-mode=off即可關閉。

application.properties

spring.main.banner-mode=off


或是在進入點@SpringBootApplication類使用SpringApplicationBuilder.bannerMode()帶入Banner.Mode.OFF

DemoApplication

package com.abc.demo;

import org.springframework.boot.Banner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        new SpringApplicationBuilder(DemoApplication.class)
                .bannerMode(Banner.Mode.OFF)
                .run(args);
    }

}


沒有留言:

張貼留言