How do you customize or disable the Spring Boot startup banner?
answer
- banner.txt at classpath root
- spring.main.banner-mode = console|log|off
- ${application.version}, ${AnsiColor.*}
- Banner interface: printBanner()
- image banner: banner.png
basics
~10 sPut a banner.txt file on the classpath root and Spring Boot prints it at startup. To turn it off, set spring.main.banner-mode=off in application.properties.
solid answer
~30 sSpring Boot looks for a `banner.txt` at the classpath root by default and prints it during startup; change the path with `spring.banner.location`, or use an image (`banner.gif/png/jpg`). The file supports placeholders like `${application.version}`, `${spring-boot.version}`, and ANSI color codes such as `${AnsiColor.GREEN}`. To disable it, set `spring.main.banner-mode=off` (values: `console`, `log`, `off`), or call `new SpringApplicationBuilder().bannerMode(Banner.Mode.OFF)`. For fully programmatic control implement the `Banner` interface and pass it to `SpringApplication.setBanner(...)`; its `printBanner(Environment, Class<?>, PrintStream)` method lets you write anything you want. The banner is purely cosmetic — it has no effect on application behavior.
code
java · 14 lines// Programmatic custom banner
public class MyBanner implements Banner {
@Override
public void printBanner(Environment env, Class<?> sourceClass, PrintStream out) {
out.println("=== KataJob starting on profile: "
+ String.join(",", env.getActiveProfiles()) + " ===");
}
}
public static void main(String[] args) {
SpringApplication app = new SpringApplication(App.class);
app.setBanner(new MyBanner()); // or app.setBannerMode(Banner.Mode.OFF);
app.run(args);
}go deeper
Know banner.txt on the classpath and spring.main.banner-mode=off.
Know placeholders, image banners, and the three banner modes (console/log/off).
Know the Banner interface and its printBanner signature for programmatic banners.
Treat it as trivia — but understand the manifest-version gotcha and ANSI fallback for log-hygiene decisions.
The **startup banner** is the ASCII art ("Spring" by default) printed to the console when a Spring Boot application boots. It is cosmetic only and useful for identifying which app/version started. ### Text banner: `banner.txt` By default Spring Boot's `SpringApplicationBannerPrinter` looks for a file named `banner.txt` at the **root of the classpath** (e.g. `src/main/resources/banner.txt`). If found, its contents are printed. Override the location with `spring.banner.location=classpath:my-banner.txt`. Character encoding is controlled by `spring.banner.charset` (default UTF-8). ### Placeholders Inside `banner.txt` you can use property placeholders resolved from the `Environment`, plus special ones: - `${application.version}` / `${application.formatted-version}` — from the `Implementation-Version` in `MANIFEST.MF` (only populated when running the built jar, blank in the IDE). - `${spring-boot.version}` / `${spring-boot.formatted-version}` — the Spring Boot version. - `${application.title}` — the `Implementation-Title` manifest attribute. - **ANSI colors**: `${AnsiColor.RED}`, `${AnsiColor.GREEN}`, `${AnsiStyle.BOLD}`, `${AnsiBackground.BLUE}`, etc. These only render if ANSI output is enabled (`spring.output.ansi.enabled=always|detect|never`). ### Image banners Drop a `banner.gif`, `banner.jpg`, or `banner.png` on the classpath root and Spring Boot converts it to ASCII/ANSI art. Tune with `spring.banner.image.width`, `.height`, `.invert`, etc. ### Banner modes The property `spring.main.banner-mode` (enum `Banner.Mode`) controls where/whether it prints: - `console` (default) — writes to `System.out`. - `log` — writes via the logging system at INFO. - `off` — no banner. Equivalent programmatic calls: `SpringApplication.setBannerMode(Banner.Mode.OFF)` or `new SpringApplicationBuilder(App.class).bannerMode(Banner.Mode.OFF).run(args)`. ### The `Banner` interface (fully custom) For arbitrary logic implement `org.springframework.boot.Banner`: ```java void printBanner(Environment environment, Class<?> sourceClass, PrintStream out); ``` Register it with `SpringApplication.setBanner(new MyBanner())`. This gives you the live `Environment`, so you can print any runtime info. ### Gotchas - `${application.version}` is empty when launched from the IDE because there is no jar manifest — it only fills in from a built, packaged jar. - ANSI colors silently fall back to plain text when ANSI is not supported (e.g. piped output, some CI logs). - The banner is printed **before** most of the context is refreshed, so don't rely on beans being available inside a custom `Banner`.
- Why is ${application.version} blank when I run from IntelliJ?That placeholder reads Implementation-Version from the jar's MANIFEST.MF. Running exploded classes from an IDE has no manifest, so it resolves to empty. Build and run the packaged jar and it appears.
- Thinking disabling the banner speeds up or changes application behavior meaningfully
- Claiming you must edit Spring Boot source to change the banner
- Believing ANSI colors always render regardless of terminal support