4 ways to bootstrap a Spring Boot Application

There are several ways to bootstrap a Spring Boot standalone application. One way to do it is by implementing the org.springframework.boot.CommandLineRunner interface and implementing the run(String… args) method. This is useful when you want to execute jobs or services, such as send a notification about the application or execute a SQL statement to update some … Read more

Spring Boot CLI Commands

The Spring Boot CLI is a powerful tool to create/manage your projects. By executing the command with the ‘–help’ parameter, you will see the list of available options: ./spring –helpusage: spring [–help] [–version]        <command> [<args>]Available commands are:  run [options] <files> [–] [args]    Run a spring groovy script  grab                    Download a spring groovy script’s … Read more

Passing Command Line Arguments in Spring Boot applications

Spring Boot has a quite sophisticated environment variable and config properties management. Using the @Value Annotation In general terms, you can pass arguments with -DargumentName . For example: -DargumentName=”value1″ Then in your Spring Boot application, you can retrieve the value by doing: @Value(“${argumentName}”) private String myVariable Using the @Component Bean But you can do it … Read more

How to change Spring Boot default Banner

You should have noticed that when you run a Spring Boot application a banner is displayed at the beginning of the application. For your own purposes, you can customize the starting banner by implementing the org.springframework.boot.Banner interface. Let’s see an example of it: package com.demo; import java.io.PrintStream; import org.springframework.boot.Banner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.core.env.Environment; … Read more

Configure SpringBoot logging via application.properties

In a standard Spring Boot web application, the file application.properties is located under the resources folder: To understand how Spring Boot Logging works, let’s consider an application with an empty application.yml file. private final Logger log = LoggerFactory.getLogger(this.getClass()); @RequestMapping(“/”) public String home(Map<String, Object> model) { log.debug(“This is a debug message”); log.info(“This is an info message”); … Read more