Skip to content

Commit 74d520f

Browse files
committed
Polish @value documentation in the Reference Manual
See gh-23052
1 parent 6ac6839 commit 74d520f

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/docs/asciidoc/core/core-beans.adoc

+20-14
Original file line numberDiff line numberDiff line change
@@ -5263,6 +5263,7 @@ named "customerPreferenceDao" and then falls back to a primary type match for th
52635263
----
52645264

52655265
With the following configuration:
5266+
52665267
[source,java,indent=0]
52675268
[subs="verbatim,quotes"]
52685269
----
@@ -5272,6 +5273,7 @@ With the following configuration:
52725273
----
52735274

52745275
And the following `application.properties` file:
5276+
52755277
[source,java,indent=0]
52765278
[subs="verbatim,quotes"]
52775279
----
@@ -5282,7 +5284,7 @@ In that case, the `catalog` parameter and field will be equal to the `MovieCatal
52825284

52835285
A default lenient embedded value resolver is provided by Spring. It will try to resolve the
52845286
property value and if it cannot be resolved, the property name (for example `${catalog.name}`)
5285-
will be injected as the value. If you want to maintain strict control over non existent
5287+
will be injected as the value. If you want to maintain strict control over nonexistent
52865288
values, you should declare a `PropertySourcesPlaceholderConfigurer` bean, as the following
52875289
example shows:
52885290

@@ -5293,22 +5295,26 @@ example shows:
52935295
public class AppConfig {
52945296
52955297
@Bean
5296-
public PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
5298+
public static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
52975299
return new PropertySourcesPlaceholderConfigurer();
52985300
}
52995301
}
53005302
----
53015303

5302-
Using the above configuration ensures Spring initialization failure if any of `${}`
5304+
NOTE: When configuring a `PropertySourcesPlaceholderConfigurer` using JavaConfig, the
5305+
`@Bean` method must be `static`.
5306+
5307+
Using the above configuration ensures Spring initialization failure if any `${}`
53035308
placeholder could not be resolved. It is also possible to use methods like
5304-
`setPlaceholderPrefix`, `setPlaceholderSuffix` or `setValueSeparator` to customize placeholders.
5309+
`setPlaceholderPrefix`, `setPlaceholderSuffix`, or `setValueSeparator` to customize
5310+
placeholders.
53055311

53065312
NOTE: Spring Boot configures by default a `PropertySourcesPlaceholderConfigurer` bean that
53075313
will get properties from `application.properties` and `application.yml` files.
53085314

53095315
Built-in converter support provided by Spring allows simple type conversion (to `Integer`
5310-
or `int` for example) to be automatically handled. Multiple comma separated values parameter
5311-
can be automatically converted to String array without extra effort.
5316+
or `int` for example) to be automatically handled. Multiple comma-separated values can be
5317+
automatically converted to String array without extra effort.
53125318

53135319
It is possible to provide a default value as following:
53145320

@@ -5326,10 +5332,10 @@ It is possible to provide a default value as following:
53265332
}
53275333
----
53285334

5329-
Spring BeanPostProcessor uses ConversionService instance behind the scene to handle the
5330-
process from converting `@Value` value to the target type. If you want to provide conversion
5331-
support for your own custom type, you can provide your own ConversionService bean instance
5332-
as the following example shows:
5335+
A Spring `BeanPostProcessor` uses a `ConversionService` behind the scene to handle the
5336+
process for converting the String value in `@Value` to the target type. If you want to
5337+
provide conversion support for your own custom type, you can provide your own
5338+
`ConversionService` bean instance as the following example shows:
53335339

53345340
[source,java,indent=0]
53355341
[subs="verbatim,quotes"]
@@ -5346,8 +5352,8 @@ as the following example shows:
53465352
}
53475353
----
53485354

5349-
<<expressions, `SpEL` expression>> built-in support allows dynamically computed `@Value`
5350-
at runtime as in the following example shows:
5355+
When `@Value` contains a <<expressions, `SpEL` expression>> the value will be dynamically
5356+
computed at runtime as the following example shows:
53515357

53525358
[source,java,indent=0]
53535359
[subs="verbatim,quotes"]
@@ -5357,13 +5363,13 @@ at runtime as in the following example shows:
53575363
53585364
private final String catalog;
53595365
5360-
public MovieRecommender(@Value("#{systemProperties['user.catalog'] + 'Catalog' }") String catalog){
5366+
public MovieRecommender(@Value("#{systemProperties['user.catalog'] + 'Catalog' }") String catalog) {
53615367
this.catalog = catalog;
53625368
}
53635369
}
53645370
----
53655371

5366-
SpEL also enables to use more complex data structure:
5372+
SpEL also enables the use of more complex data structures:
53675373

53685374
[source,java,indent=0]
53695375
[subs="verbatim,quotes"]

0 commit comments

Comments
 (0)