@value
The document shows that
A common use case is to assign default values ββusing the style expressions "# {systemProperties.myProp}".
These are actually three phases:
- Spring get string annotations -
AutowiredAnnotationBeanPostProcessor - Spring get property value from annotation metadata -
Environmen - Spring interpret property value -
ExpressionParser
User case
If we define a test.foo in application.yml , as you described:
-- application.yml -- test.foo: ${test.bar:
Then we refer to it in the code via @Value , it works as you said.
@Autowired public A(@Value("test.foo") Object a) {}
But if we get it directly from the environment , it will be a simple line:
env.getProperty("test.foo")
More details
So, regardless of whether it works or not, it depends on how you used it. I can no longer provide additional information. Hope the following related post might help.
source share