Chapter 5. Working with configuration properties

 

This chapter covers

  • Fine-tuning autoconfigured beans
  • Applying configuration properties to application components
  • Working with Spring profiles

Do you remember when the iPhone first came out? A small slab of metal and glass hardly fit the description of what the world had come to recognize as a phone. And yet, it pioneered the modern smartphone era, changing everything about how we communicate. Although touch phones are in many ways easier and more powerful than their predecessor, the flip phone, when the iPhone was first announced, it was hard to imagine how a device with a single button could be used to place calls.

In some ways, Spring Boot autoconfiguration is like this. Autoconfiguration greatly simplifies Spring application development. But after a decade of setting property values in Spring XML configuration and calling setter methods on bean instances, it’s not immediately apparent how to set properties on beans for which there’s no explicit configuration.

Fortunately, Spring Boot provides a way with configuration properties. Configuration properties are nothing more than properties on beans in the Spring application context that can be set from one of several property sources, including JVM system properties, command-line arguments, and environment variables.

5.1. Fine-tuning autoconfiguration

5.2. Creating your own configuration properties

5.3. Configuring with profiles

Summary

sitemap