when use @Value, you should add @PropertySource annotation on Class, or specify properties holder in spring's xml file. eg.
@Component
@PropertySource("classpath:config.properties")
public class BusinessClass{
@Value("${user.name}")
private String name;
@Value("${user.age}")
private int age;
@Value("${user.registed:false}")
private boolean registed;
}
config.properties
user.name=test
user.age=20
user.registed=true
this works!
Of course, you can use placeholder xml configuration instead of annotation. spring.xml
<context:property-placeholder location="classpath:config.properties"/>