Skip to content

Profiles added using @ActiveProfiles have different precedence #28530

@asibross

Description

@asibross

See this example that demonstrates the issue:

@SpringBootTest @ActiveProfiles("smoketest") class SmokeTests { @Autowired private Environment environment; @Test void testProfileOrderSB25() { Assertions.assertArrayEquals(new String[]{"smoketest", "dev"}, environment.getActiveProfiles()); } @Test void testProfileOrderSB23() { Assertions.assertArrayEquals(new String[]{"dev", "smoketest"}, environment.getActiveProfiles()); } } 

The dev profile is activated using an EnvironmentPostProcessor.

@Order(Ordered.HIGHEST_PRECEDENCE) public class ProfileActivationEPP implements EnvironmentPostProcessor { @Override public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { environment.addActiveProfile("dev"); } } 

The different order demonstrated above will affect the order application-<profile>.properties are added and thus the value of overridden properties.

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