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
277da462
Commit
277da462
authored
Jul 11, 2016
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document differences between @Value and @ConfigurationProperties
Closes gh-4892
parent
a72e4948
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
2 deletions
+39
-2
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+39
-2
No files found.
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
277da462
...
@@ -734,8 +734,8 @@ Nested POJO properties can also be created (so a setter is not mandatory) if the
...
@@ -734,8 +734,8 @@ Nested POJO properties can also be created (so a setter is not mandatory) if the
default constructor, or a constructor accepting a single value that can be coerced from
default constructor, or a constructor accepting a single value that can be coerced from
String. Some people use Project Lombok to add getters and setters automatically.
String. Some people use Project Lombok to add getters and setters automatically.
NOTE: Contrary to `@Value`, SpEL expressions are not evaluated prior to injecting a value
TIP: See also the <<boot-features-external-config-vs-value,differences between `@Value`
in the relevant `@ConfigurationProperties` bean
.
and `@ConfigurationProperties`>>
.
The `@EnableConfigurationProperties` annotation is automatically applied to your project
The `@EnableConfigurationProperties` annotation is automatically applied to your project
so that any beans annotated with `@ConfigurationProperties` will be configured from the
so that any beans annotated with `@ConfigurationProperties` will be configured from the
...
@@ -954,6 +954,43 @@ _<<production-ready-features.adoc#production-ready-endpoints, Production ready f
...
@@ -954,6 +954,43 @@ _<<production-ready-features.adoc#production-ready-endpoints, Production ready f
section for details.
section for details.
[[boot-features-external-config-vs-value]]
==== @ConfigurationProperties vs. @Value
`@Value` is a core container feature and it does not provide the same features as type-safe
Configuration Properties. The table below summarizes the features that are supported by
`@ConfigurationProperties` and `@Value`:
[cols="4,2,2"]
|===
|Feature |`@ConfigurationProperties` |`@Value`
| <<boot-features-external-config-relaxed-binding,Relaxed binding>>
| Yes
| No
| <<appendix-configuration-metadata.adoc#configuration-metadata,Meta-data support>>
| Yes
| No
| `SpEL` evaluation
| No
| Yes
|===
If you define a set of configuration keys for your own components, we recommend you to
group them in a pojo annotated with `@ConfigurationProperties`. Please also be aware
that since `@Value` does not support relaxed binding, it isn't a great candidate if you
need to provide the value using environment variables.
Finally, while you can write a `SpEL` expression in `@Value`, such expressions are not
processed from <<boot-features-external-config-application-property-files,Application
property files>>.
[[boot-features-profiles]]
[[boot-features-profiles]]
== Profiles
== Profiles
Spring Profiles provide a way to segregate parts of your application configuration and
Spring Profiles provide a way to segregate parts of your application configuration and
...
...
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