Spring @Value Annotation Example
![Image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiImXsueEDi1ZbZ4-PmbKe3jmByb488rd15rrhFbxTy4GV4wgF9vaW6aE6I-MHZTe56J4YBXeXizsrB5Q_HJHc58QlMyHG_SP0FnuRPXSW13qo_lpZN954DjLFJqWA49MVuxsnnkIUsd9wGtRP7oNZq_JOYOqHnodp7BgnABS5rZVD4DjUisn0YOqKGig/w400-h185/valueannotation.png)
In this section we will learn about @Value Annotation. Note This annotation can be used for injecting values into fields in Spring-managed beans, and it can be applied at the field or constructor/method parameter level. It is used to assign default values to variables and method arguments. We can read spring environment variables as well as system variables using @Value annotation. Spring @Value annotation also supports SpEL. Let’s look at some of the examples of using @Value annotation. 1. Set Default/Static Value We can assign a class member variable with default/static value using @Value annotation. // Set static string value @Value ( "Hi, This is a static message." ) private String staticMessage ; // Set default boolean value @Value ( "true" ) private boolean booleanValue ; // Set static integer value @Value ( "234" ) private int integerValue ; 2. Get Value from Properties File @Value can be used to read values from the properties file. 2.1 Ge