Usually when you start a Spring Boot application you have something like this in your console output :
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.5.5)
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);
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**
here I used a image of Stich as a banner, and had this output
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.
In addition, the text can be coloured with variables such as ${AnsiColor.NAME} or ${AnsiBackground.NAME}.
Top comments (0)