I'm Spring newbie and I'm wondering what are prerequisites/conditions of using @Value annotation in Spring?
What I have for now is a Token class which has hardcoded secret key as a field. What I'm trying to do is to move this secret key to config file to eliminate hardcoding but for some reason the following is not working.
public class Token {
//...some code
@Value("${my.secretKey}")
private String key;
//...some code
}
Maybe there is any standard technique to solving this type of tasks.
Thanks for help!
p.s. I have .properties
file which contains my.secretKey=123
entry.