spring-projects / spring-projects/spring-boot

Allow a programatically configured banner to override the default banner

Open
#47,705 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: pending-design-work type: enhancement
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

Using Spring Boot v4 M3 and JDK 25, I have a simple app that does this:

        new SpringApplicationBuilder()
            .banner(new MyBanner())
            // other stuff happens here
            .run(args);

As the documentation indicates, this is a fallback banner in case no banner is found as a resource. I'd like Spring Boot, if possible, to offer a way where the Banner implementation set here overrides any and all banner resources defined; IOW, let this be the primary banner and not the fallback. Perhaps introduce a new "Banner Mode" option?

The annoyance I am running into is that our app creates its own banner programmatically, and yet if we ship the app with a library that has its own banner.txt on the classpath (i.e. Spring Cloud) our banner is ignored and the resource takes over, which seems to me to be both "as intended" and somewhat odd.

If not, it would be good for the documentation to recommend how such a use case could be handled, so one could define and override their own "banner selection" logic, which at the moment is sort of hidden here:

private @Nullable Banner printBanner(ConfigurableEnvironment environment) {
		if (this.properties.getBannerMode(environment) == Banner.Mode.OFF) {
			return null;
		}
		ResourceLoader resourceLoader = (this.resourceLoader != null) ? this.resourceLoader
				: new DefaultResourceLoader(null);
		SpringApplicationBannerPrinter bannerPrinter = new SpringApplicationBannerPrinter(resourceLoader, this.banner);
		if (this.properties.getBannerMode(environment) == Mode.LOG) {
			return bannerPrinter.print(environment, this.mainApplicationClass, logger);
		}
		return bannerPrinter.print(environment, this.mainApplicationClass, System.out);
	}

Thank you.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the printBanner method shown in the issue and trace how SpringApplicationBuilder.banner(...) reaches SpringApplicationBannerPrinter. Review the existing banner resource precedence and Banner.Mode handling, then define and test behavior where a programmatic Banner overrides classpath resources, or document the supported customization path.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.