chapter two

2 Spring Boot Common Tasks

 

This chapter covers:

  • Managing Configurations in a Spring Boot application
  • Creating Custom configuration with @ConfigurationProperties
  • Exploring CommandLineRunner interface to execute initialization code
  • Understanding Spring Boot default logging and configuring Log4j2 logging
  • How to validate user data in a Spring Boot application using Bean Validation

By this point, we’ve learned a bit about what Spring Boot is and learned its purpose to improve the application development experience by abstracting specific low-level configurations. In this chapter, you’ll extend this understanding further by learning few core concepts such as how to manage application configuration and create a custom configuration for your application. You’ll also use Spring Boot to perform several commonly used tasks that you’ll frequently perform while developing Spring Boot applications.

2.1    Managing Configurations

2.1.1   Using SpringApplication

2.1.2   Using @PropertySource

2.1.3   Config Data File

2.1.4   OS Environment Variable

2.1.5   Command Line Arguments

2.2    Creating Custom Properties with @ConfigurationProperties

2.3    Executing Code on Spring Boot Application Startup

2.4    Customizing logging Logging in a Spring Boot Application

2.5    Validate User Data using Bean Validation

2.6    Chapter Summary