Document the semantic of using multiple profile expressions
This commit clarifies the semantic of declaring multiple profile expression with the "spring.config.activate.on-profile" property. See gh-44866 Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
This commit is contained in:
parent
8404736630
commit
6eae09ba68
|
@ -545,7 +545,9 @@ The following activation properties are available:
|
|||
| Property | Note
|
||||
|
||||
| `on-profile`
|
||||
| A profile expression that must match for the document to be active.
|
||||
| A profile expression that must match for the document to be active,
|
||||
or a list of profile expressions of which at least one must match for the document to be active.
|
||||
Please note comma-separated list such as `foo,bar` is equal to `foo\|bar` instead of `foo&bar`.
|
||||
|
||||
| `on-cloud-platform`
|
||||
| The javadoc:org.springframework.boot.cloud.CloudPlatform[] that must be detected for the document to be active.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -200,6 +200,17 @@ class ConfigDataPropertiesTests {
|
|||
assertThat(properties.isActive(context)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isActiveAgainstBoundDataWhenProfilesMatchCommaSeparatedList() {
|
||||
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
|
||||
source.put("spring.config.activate.on-profile", "a&b,nonexistent");
|
||||
Binder binder = new Binder(source);
|
||||
ConfigDataProperties properties = ConfigDataProperties.get(binder);
|
||||
ConfigDataActivationContext context = new ConfigDataActivationContext(NULL_CLOUD_PLATFORM,
|
||||
createTestProfiles());
|
||||
assertThat(properties.isActive(context)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void getImportOriginWhenCommaListReturnsOrigin() {
|
||||
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
|
||||
|
|
Loading…
Reference in New Issue