Skip to content

Warn that multi-document property files cannot be loaded by using @PropertySource or @TestPropertySource #24945

Closed
@peter-thomas-mgd

Description

@peter-thomas-mgd

Expected behavior is that a multi-document properties file can be created with different sections separated by "#--- " characters, for each section applicable to a given active profile. This works as expected when using a file named application.properties and allowing Spring Boot to bootstrap the application normally.

However, if the default application properties file is overridden in a JUnit test class annotated with a test property source (e.g. @TestPropertySource(locations="classpath:test.properties")), Spring Boot ignores the active profiles and simply references the last value it finds for the property in the properties file.

I have created a sample Java project to demonstrate the issue here: https://github.com/peter-thomas-mgd/spring-multi-doc

The example shows how an identical properties file behaves differently when specified as a test property source called test.properties vs. when bootstrapped as the default application.properties.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions