Hello guys , I hope you are doing well 🙂

I would like to share with you an  amazing tip about Spring Boot .

But , are you fed up with the default Banner displayed in the console each time you run a Spring Boot Application  ?

If Yes , Great , I will show you how to customize it in order to print instead your own message 🙂

Just create a simple Spring Boot application ( I do it via Spring Initializr )

Inside the main method of your annotated Spring Boot Application  , you need just to implement the org.springframework.boot.Banner interface  ( I used lambda expression to implement the Banner interface ) 

@SpringBootApplication
public class SpringBootBasicApplication {

public static void main(String[] args) {
SpringApplication app = new
SpringApplication(SpringBootBasicApplication.class);
app.setBanner(
(Environment environment, Class<?> sourceClass, PrintStream out) -> {
out.print("\n\n\t Customized Banner : BLOG Java Ways\n\n".toUpperCase());
});
app.run(args);
}

 Just Run again your Spring boot Application , you will get this :

But I need  my own ASCII banner and display it  !

Yes , My friend ! there is a cool web site which we can use to generate a customized ASCII banner to integrate in our Sring Boot Application , check this  website 

 I created a custom banner and save it to a text file named banner.txt

and that ‘s it !  place the file under your project ( resources directory )

By default, Spring Boot looks for the banner.txt file in the classpath , so it will load automatically this resource file for you .

 Our Code source is the simplest one : 

@SpringBootApplication
public class SpringBootBasicApplication {


public static void main(String[] args) {
SpringApplication.run(SpringBootBasicApplication.class, args);

}

The final result in your console :

I hope you enjoyed this today’s tip 🙂 

Have a great day !

7+

Mohamed Ben Hassine

Hello , I am a Software Technical Leader  / Lover / Speaker / Blogger / Trainer with over 9 years of experience in designing and developing financial and telecommunication large scale enterprise applications using Web / Java/JEE technologies. Open to multi-culture customers and workplaces, I help companies and individuals build scalable Web Applications using last proved web technologies and enterprise software architectures.

2 Comments

Rabeb · 10 January 2019 at 11 h 34 min

I like it 🙂

    Mohamed · 10 January 2019 at 12 h 01 min

    Welcome dear Rabeb 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *