I can't understand how spring boot handles annotation @Value. When I inject value to my field of class(with @Value), handler takes that value from Spring Environement or directly from application.properties/application.yaml?
Asked
Active
Viewed 55 times
0
-
can you share the code you have tried? it will be helpful to understand the issue. – dassum Sep 19 '22 at 14:39
-
@dassum public class MyClass { Value("${text}") private String someText; } and i have got application.properties: text=Hello world! BeanPostProcessor for Value annotation is used by the Spring Environment or application.properties? – egor Sep 19 '22 at 15:27
1 Answers
0
The answer to your question (does the value come from the Environment or from the application.yaml?) is yes, the value comes from the environment or from the application.yaml file.
Here is a reasonable writeup on the @Value annotation: https://www.baeldung.com/spring-value-annotation
In the Baeldung article, SpEL stands for Spring Expression Language.

DwB
- 37,124
- 11
- 56
- 82