Skip to content

denisab85/spring-property-overriding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Spring Property Overriding Demo

This Spring Boot application is a sample project specifically designed to demonstrate property overriding behavior in a Spring Boot configuration.

Purpose

The purpose of this application is to show the specifics of the properties overriding mechanism in a Spring Boot project.

Structure

  • ApplicationPropertiesHolder class maps its fields to corresponding properties to be loaded from different property sources. The expectation is, while each property/field is defined in either application.properties or app.properties, both should be overridden by same-name values in override.properties.
  • AdditionalConfigurationFilesAdder class adds additional property sources to the application's environment. The added sources will override values defined in application.properties including profile-specific application-*.properties.
  • Application class serves as the entry point of the application.

Usage

To run the project, follow these steps:

  1. Ensure that you have Java and Maven installed on your system.
  2. Clone the repository and navigate to the project directory.
  3. Build the project using the command: mvn clean install
  4. Run the application using the command: mvn test

Properties Files Used

  • application.properties: defines the application field in the ApplicationPropertiesHolder class.
  • app.properties: defines the app field in the ApplicationPropertiesHolder class.
  • override.properties: overrides both app and application properties.

Tests

The PropertiesConfigTest class includes two test methods:

  • definedInAppProperties(): verifies that the value of the app
  • property is overridden as expected according to override.properties.
  • definedInApplicationProperties(): asserts that the value of the
  • application property is overridden according to override.properties.

Links

The specifics of Spring Boot property overriding behavior discussed on GitHub and on StackOverflow:

About

Property overriding bug demo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages