java - How to inject property value using @Value into static fields - Stack Overflow
@Value("${value}") public void setOutputPath(String outputPath) { AClass.outputPath = outputPath; } However you should avoid doing this. Spring is not designed for static injections. Thus you should use another way to set this field at start of your application, e.g. constructor. Anyway @Value annotation uses springs PropertyPlaceholder which is still resolved after static fields are initialized. Thus you won't have any advantages for this constructi
Read full article from java - How to inject property value using @Value into static fields - Stack Overflow
No comments:
Post a Comment