Spring Property Injection Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 9: Line 9:
=The Environment Abstraction=
=The Environment Abstraction=


<span id='Configuration_Property'></span>'''Configuration properties''' are pieces of data coded into Spring components using the [[JavaBeans#Overview|JavaBeans convention]]. They usually have a corresponding member variable, a getter and a setter.
<span id='Configuration_Property'></span>'''Configuration properties''' are pieces of data coded into Spring components using the [[JavaBeans#Overview|JavaBeans conventions]] referring to properties. They usually have a corresponding member variable, a getter and a setter.


=Injecting Properties into Beans=
=Injecting Properties into Beans=

Revision as of 19:19, 21 November 2018

Internal

Overview

This section refers to property injection, which is the process that allows external data, known as configuration properties, to be provided to the application runtime at startup or while it is running, in form of Java system properties, environment variables and other means. The component configuration, or bean wiring, is addressed in the "Dependency Injection and Inversion of Control Container Concepts - Configuration Model" section.

The Environment Abstraction

Configuration properties are pieces of data coded into Spring components using the JavaBeans conventions referring to properties. They usually have a corresponding member variable, a getter and a setter.

Injecting Properties into Beans

Property Injection and Auto-Configuration

Sources of Properties

Precedence

Profiles




application.properties

application.properties

Application Arguments

Environment Variables

Profile

TODO

  • Diagram with property sources and their relative priority, including the configuration service (chapter 14).
  • Augment https://kb.novaordis.com/index.php/Spring_Boot_Concepts#Autoconfiguration with specialized sections on property injection for DataSources, etc.
  • How do I read the effective values of all configuration properties during testing and at runtime?
  • You can figure out the active profile from within a Spring application by @Autowire-ing org.springframework.core.env.Environment and inspecting it.