Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
12a921c2
Commit
12a921c2
authored
Dec 09, 2015
by
Johnny Lim
Committed by
Stephane Nicoll
Dec 09, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish docs
Closes gh-4709
parent
578eaa26
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
11 deletions
+11
-11
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+7
-7
ConfigFileApplicationListener.java
...rk/boot/context/config/ConfigFileApplicationListener.java
+2
-2
ConfigFileApplicationListenerTests.java
...ot/context/config/ConfigFileApplicationListenerTests.java
+2
-2
No files found.
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
12a921c2
...
@@ -475,13 +475,13 @@ defined using the naming convention `application-{profile}.properties`. The
...
@@ -475,13 +475,13 @@ defined using the naming convention `application-{profile}.properties`. The
used if no active profiles are set (i.e. if no profiles are explicitly activated
used if no active profiles are set (i.e. if no profiles are explicitly activated
then properties from `application-default.properties` are loaded).
then properties from `application-default.properties` are loaded).
Profile
specific properties are loaded from the same locations as standard
Profile
-
specific properties are loaded from the same locations as standard
`application.properties`, with profile-specific files always overriding the non-specific
`application.properties`, with profile-specific files always overriding the non-specific
ones irrespective of whether the profile-specific files are inside or outside your
ones irrespective of whether the profile-specific files are inside or outside your
packaged jar.
packaged jar.
If several profiles are specified, a last wins strategy applies. For example, profiles
If several profiles are specified, a last wins strategy applies. For example, profiles
specified by the `spring.
active.profiles
` property are added after those configured via
specified by the `spring.
profiles.active
` property are added after those configured via
the `SpringApplication` API and therefore take precedence.
the `SpringApplication` API and therefore take precedence.
...
@@ -930,7 +930,7 @@ properties, the highest `PropertySource` will win. This means that you can speci
...
@@ -930,7 +930,7 @@ properties, the highest `PropertySource` will win. This means that you can speci
active profiles in `application.properties` then *replace* them using the command line
active profiles in `application.properties` then *replace* them using the command line
switch.
switch.
Sometimes it is useful to have profile
specific properties that *add* to the active
Sometimes it is useful to have profile
-
specific properties that *add* to the active
profiles rather than replace them. The `spring.profiles.include` property can be used
profiles rather than replace them. The `spring.profiles.include` property can be used
to unconditionally add active profiles. The `SpringApplication` entry point also has
to unconditionally add active profiles. The `SpringApplication` entry point also has
a Java API for setting additional profiles (i.e. on top of those activated by the
a Java API for setting additional profiles (i.e. on top of those activated by the
...
@@ -963,8 +963,8 @@ possible to activate profiles using Spring's `ConfigurableEnvironment` interface
...
@@ -963,8 +963,8 @@ possible to activate profiles using Spring's `ConfigurableEnvironment` interface
[[boot-features-profile-specific-configuration]]
[[boot-features-profile-specific-configuration]]
=== Profile
specific configuration files
=== Profile
-
specific configuration files
Profile
specific variants of both `application.properties` (or `application.yml`) and
Profile
-
specific variants of both `application.properties` (or `application.yml`) and
files referenced via `@ConfigurationProperties` are considered as files are loaded.
files referenced via `@ConfigurationProperties` are considered as files are loaded.
See _<<boot-features-external-config-profile-specific-properties>>_ for details.
See _<<boot-features-external-config-profile-specific-properties>>_ for details.
...
@@ -1045,7 +1045,7 @@ converter will color the output according to the log level, for example:
...
@@ -1045,7 +1045,7 @@ converter will color the output according to the log level, for example:
[source,indent=0]
[source,indent=0]
----
----
%clr(
-%5p}
)
%clr(
%5p
)
----
----
The mapping of log level to a color is as follows:
The mapping of log level to a color is as follows:
...
@@ -1259,7 +1259,7 @@ it's loaded too early. You need to either use `logback-spring.xml` or define a
...
@@ -1259,7 +1259,7 @@ it's loaded too early. You need to either use `logback-spring.xml` or define a
==== Profile
specific configuration
==== Profile
-
specific configuration
The `<springProfile>` tag allows you to optionally include or exclude sections of
The `<springProfile>` tag allows you to optionally include or exclude sections of
configuration based on the active Spring profiles. Profile sections are supported anywhere
configuration based on the active Spring profiles. Profile sections are supported anywhere
within the `<configuration>` element. Use the `name` attribute to specify which profile
within the `<configuration>` element. Use the `name` attribute to specify which profile
...
...
spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java
View file @
12a921c2
...
@@ -425,7 +425,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
...
@@ -425,7 +425,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
// Search for a file with the given name
// Search for a file with the given name
for
(
String
ext
:
this
.
propertiesLoader
.
getAllFileExtensions
())
{
for
(
String
ext
:
this
.
propertiesLoader
.
getAllFileExtensions
())
{
if
(
profile
!=
null
)
{
if
(
profile
!=
null
)
{
// Try the profile
specific file
// Try the profile
-
specific file
loadIntoGroup
(
group
,
location
+
name
+
"-"
+
profile
+
"."
+
ext
,
loadIntoGroup
(
group
,
location
+
name
+
"-"
+
profile
+
"."
+
ext
,
null
);
null
);
for
(
String
processedProfile
:
this
.
processedProfiles
)
{
for
(
String
processedProfile
:
this
.
processedProfiles
)
{
...
@@ -440,7 +440,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
...
@@ -440,7 +440,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
loadIntoGroup
(
group
,
location
+
name
+
"-"
+
profile
+
"."
+
ext
,
loadIntoGroup
(
group
,
location
+
name
+
"-"
+
profile
+
"."
+
ext
,
profile
);
profile
);
}
}
// Also try the profile
specific section (if any) of the normal file
// Also try the profile
-
specific section (if any) of the normal file
loadIntoGroup
(
group
,
location
+
name
+
"."
+
ext
,
profile
);
loadIntoGroup
(
group
,
location
+
name
+
"."
+
ext
,
profile
);
}
}
}
}
...
...
spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java
View file @
12a921c2
...
@@ -194,7 +194,7 @@ public class ConfigFileApplicationListenerTests {
...
@@ -194,7 +194,7 @@ public class ConfigFileApplicationListenerTests {
assertEquals
(
"myprofile"
,
StringUtils
assertEquals
(
"myprofile"
,
StringUtils
.
arrayToCommaDelimitedString
(
this
.
environment
.
getActiveProfiles
()));
.
arrayToCommaDelimitedString
(
this
.
environment
.
getActiveProfiles
()));
String
property
=
this
.
environment
.
getProperty
(
"the.property"
);
String
property
=
this
.
environment
.
getProperty
(
"the.property"
);
// The value from the second file wins (no profile
specific configuration is
// The value from the second file wins (no profile
-
specific configuration is
// actually loaded)
// actually loaded)
assertThat
(
property
,
equalTo
(
"frompropertiesfile"
));
assertThat
(
property
,
equalTo
(
"frompropertiesfile"
));
}
}
...
@@ -209,7 +209,7 @@ public class ConfigFileApplicationListenerTests {
...
@@ -209,7 +209,7 @@ public class ConfigFileApplicationListenerTests {
assertEquals
(
"myprofile"
,
StringUtils
assertEquals
(
"myprofile"
,
StringUtils
.
arrayToCommaDelimitedString
(
this
.
environment
.
getActiveProfiles
()));
.
arrayToCommaDelimitedString
(
this
.
environment
.
getActiveProfiles
()));
String
property
=
this
.
environment
.
getProperty
(
"the.property"
);
String
property
=
this
.
environment
.
getProperty
(
"the.property"
);
// The value from the second file wins (no profile
specific configuration is
// The value from the second file wins (no profile
-
specific configuration is
// actually loaded)
// actually loaded)
assertThat
(
property
,
equalTo
(
"frompropertiesfile"
));
assertThat
(
property
,
equalTo
(
"frompropertiesfile"
));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment