DEV Community

Erwan Le Tutour
Erwan Le Tutour

Posted on • Edited on • Originally published at Medium

6 1

Spring Boot banner

springboot

Usually when you start a Spring Boot application you have something like this in your console output :

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.5.5)
Enter fullscreen mode Exit fullscreen mode

But did you know that you can disable it, or even create a custom one ?
No ? Yes, and it’s simple, so let’s go.

Turning banner off

If you don’t want the banner to show during the application launch you have two options :

  • Setting the property to off in your application.properties file

    spring.main.banner-mode=off

  • In your main class, change the line to run the application from this

    SpringApplication.run(BannerApplication.class, args);

to this

new SpringApplicationBuilder(BannerApplication.class)
        .bannerMode(Banner.Mode.*OFF*)
        .run(args);
Enter fullscreen mode Exit fullscreen mode

Having a custom banner

By default Spring Boot will search a file named banner.txt in your ressources folder to use it, but your banner can also be an image (that will be transformed in ASCII), so if you want to use an image you should add a property in your application.properties file

spring.banner.image.location=**classpath:banner.png**
Enter fullscreen mode Exit fullscreen mode

here I used a image of Stich as a banner, and had this output

stich

Not very beautiful nor readable, so let’s see what I have if i use a banner.txt instead of an image.

So, I created in my ressources folder, a banner.txt file, in witch i wrote “Hello the World !!” and then started my project

Simple and efficace but, we can do better, some site provide you a banner generator that let you choose the text and the font, I have faith in your use of Google to find them, but as an example you can have something like that :

You can use place holder such as thos to add some informations in your banner.

Variable Description
${application.version} The version number of your application as declared in MANIFEST.MF
${spring-boot.version} The Spring Boot version
${application.title} The title of the application as declared in MANIFEST.MF
view raw banner.csv hosted with ❤ by GitHub



In addition, the text can be coloured with variables such as ${AnsiColor.NAME} or ${AnsiBackground.NAME}.

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay