๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Back-end/JAVA & Spring

[ Spring Boot ] Banner ๋ณ€๊ฒฝ

 

 

 

 

 

๐ŸŒฑ Spring boot - Banner ๋ณ€๊ฒฝ

 

 

Spring Boot๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์‹คํ–‰๋  ๋•Œ ์ฝ˜์†”์— Spring ๋กœ๊ณ ์™€ ๋ฒ„์ „์„ ํฌํ•จํ•œ ๋ฐฐ๋„ˆ๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.

์ด๋ฅผ ์„ค์ •ํ•˜๋ ค๋ฉด ์•„๋ž˜ ๋ฐฉ๋ฒ• ์ค‘ ํ•˜๋‚˜๋ฅผ ์„ ํƒํ•˜๋ฉด ๋œ๋‹ค

 

 

 

๋ฐฐ๋„ˆ ๋น„ํ™œ์„ฑํ™” 

๋ฐฐ๋„ˆ๋ฅผ ๋น„ํ™œ์„ฑํ™”ํ•˜๋ ค๋ฉด application.properties ๋˜๋Š” application.yml ํŒŒ์ผ์— ๋‹ค์Œ ์„ค์ •์„ ์ถ”๊ฐ€

 

application.properties

spring.main.banner-mode=off

 

application.yml

spring:
  main:
    banner-mode: off

 

 

 

 

๋ฐฐ๋„ˆ ์ปค์Šคํ„ฐ๋งˆ์ด์ง•

src/main/resources ๋””๋ ‰ํ† ๋ฆฌ์— banner.txt ํŒŒ์ผ์„ ์ƒ์„ฑํ•œ ํ›„, ์›ํ•˜๋Š” ํ…์ŠคํŠธ๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ๋œ๋‹ค 

 

 

banner.txt

,--.   ,--.      ,--.                             
|  |   |  |,---. |  |,---. ,---. ,--,--,--.,---.  
|  |.'.|  | .-. :|  | .--'| .-. ||        | .-. : 
|   ,'.   \   --.|  \ `--.' '-' '|  |  |  \   --. 
'--'   '--'`----'`--'`---' `---' `--`--`--'`----'                                                
Powered by Spring Boot ${spring-boot.version}

 

 

application.properties

# banner ์„ค์ •
spring.main.banner-mode=console
spring.banner.location=banner.txt

 

 

ํ…์ŠคํŠธ ์ž…๋ ฅ์‹œ ๋ฐฐ๋„ˆ๋ฅผ ์ž๋™์œผ๋กœ ๋งŒ๋“ค์–ด์ฃผ๋Š” ์‚ฌ์ดํŠธ

https://devops.datenkollektiv.de/banner.txt/index.html

 

Spring Boot banner.txt generator

 

devops.datenkollektiv.de

 

 

ANSI ์ƒ‰์ƒ ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ์ปฌ๋Ÿฌ ๋ฐฐ๋„ˆ๋ฅผ ๋งŒ๋“ค ์ˆ˜๋„ ์žˆ๋‹ค 

${AnsiColor.RED}  ____  ${AnsiColor.YELLOW}  Spring Boot App  ${AnsiColor.DEFAULT}

 

ANSI ์ƒ‰์ƒ ํ‘œ:

  • AnsiColor.RED
  • AnsiColor.GREEN
  • AnsiColor.YELLOW
  • AnsiColor.BLUE
  • AnsiColor.MAGENTA
  • AnsiColor.CYAN
  • AnsiColor.WHITE
  • AnsiColor.DEFAULT

 

 

 

์ฝ”๋“œ๋กœ ๋ฐฐ๋„ˆ ์„ค์ •

Java ์ฝ”๋“œ๋กœ ๋ฐฐ๋„ˆ๋ฅผ ์„ค์ •ํ•˜๋ ค๋ฉด SpringAplication ๊ฐ์ฒด์— ์ง์ ‘ ๋ฐฐ๋„ˆ๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋‹ค

 

import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(Application.class);
        app.setBanner((environment, sourceClass, out) -> {
            out.println("==================================");
            out.println("    Custom Spring Boot Banner     ");
            out.println("==================================");
        });
        app.setBannerMode(Banner.Mode.CONSOLE);
        app.run(args);
    }
}