I am using Spring MVC. I have a UserService class annotated with @Service that has a lot of static variables. I would like to instantiate them with
Spring does not allow to inject value into static variables.
A workaround is to create a non static setter to assign your value into the static variable:
@Service
public class UserService {
private static String SVN_URL;
@Value("${SVN_URL}")
public void setSvnUrl(String svnUrl) {
SVN_URL = svnUrl;
}
}