Skip to content

Commit f919d26

Browse files
committed
GH-3039 Update documentation to explaine usage of Spring/Boot core propertyannotations
Resolves #3039
1 parent 1e401c8 commit f919d26

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/modules/ROOT/pages/spring-cloud-stream/configuration-options.adoc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,31 @@ Some binders let additional binding properties support middleware-specific featu
66

77
Configuration options can be provided to Spring Cloud Stream applications through any mechanism supported by Spring Boot.
88
This includes application arguments, environment variables, and YAML or .properties files.
9+
10+
IMPORTANT: Note on using Spring/Boot core property annotations.
11+
12+
Regardless whether you are dealing with a common property or binding/binder specific property, there may be times when you may need to rely on core Spring and Boot core property annotations such as `@Value` or `@ConditionalOnProperty`. For this cases make sure you specify
13+
the full name of the property.
14+
For example, given the current _application.yaml_
15+
16+
[source,yaml]
17+
----
18+
my:
19+
prop: foo
20+
spring:
21+
application:
22+
name: "messaging-test"
23+
cloud:
24+
function:
25+
definition: "produce;consume"
26+
stream:
27+
binders:
28+
rabbit:
29+
environment:
30+
my:
31+
prop: bar
32+
----
33+
If you want to inject the value of the `my.prop` from the root using `@Value` annotation, you use `(@Value("${my.prop}") String someProperty)`. And if you want the one specific to binder’s context, then you would specify
34+
full property name `(@Value(“${spring.cloud.stream.binders.rabbit.environment.my.prop}") String someProperty)`
35+
The same goes for `@ConditionalOnProperty` where you would effectively do the same.
36+

0 commit comments

Comments
 (0)