Skip to content

Profile-specific files should still be considered when processing 'spring.config.import' properties #26858

@pneyer

Description

@pneyer

SB 2.5.1 breaks our project, since profile specific properties in combination with config-imports in a multi maven module are not properly resolved anymore. This worked for us with SB 2.5.0 and SB 2.4.5

My guess it's due to issues #26754 and #26755 fixed for SB 2.5.1/2.4.7, which imho are features, not bugs.

Consider following simplified project setup, maven multi module project, two SB applications and a shared common module:

module "application FOO"

  • application.properties
    • content: spring.config.import=classpath:common.properties
  • application-local.properties
  • application-yourname.properties
  • application-prod.properties

module "application BAR"

  • application.properties
    • content: spring.config.import=classpath:common.properties
  • application-local.properties
  • application-yourname.properties
  • application-prod.properties

module "COMMON"

  • common.properties
  • common-local.properties
  • common-yourname.properties
  • common-prod.properties

We have defined some common properties per profile in module "COMMON", so we don't have to copy&paste (DRY) all properties which are needed by application FOO and application BAR. (Actually we have way more modules/applications, so it was a real hassle to refactor this some weeks ago for SB 2.4.0).
Common properties for all applications end up in "common.properties", common properties for all production environments end up in "common-prod.properties" etc.

Behavior in SB 2.5.0 (and working from 2.4.0 to SB 2.4.5):
Running "application FOO" with spring.profiles.active="local,yourname" used properties in following order (the latter overwrites to former):
COMMON/common.properties < COMMON/common-local.properties < COMMON/common-yourname.properties < FOO/application.properties < FOO/application-local.properties < FOO/application-yourname.properties

This does not work with SB 2.5.1 anymore. Application startup fails, because it cannot resolve some properties/placeholders we inject in a @Service

Please consider reverting the mentioned fixes, because SB 2.5.1 (and probably 2.4.7) is not backward compatible and break existing applications that relied on these features

See attached example project for demo, Run "DemoApplication" in demo-module with spring.profiles.active="prod". Modify SB version in parent pom.xml.
SB 2.5.0 outputs "common-prod"
SB 2.5.1 outputs "application-prod"
demo.zip

Metadata

Metadata

Assignees

Labels

type: regressionA regression from a previous release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions