I have a use case where I am using a utility class (class which contains methods that are all static and the constructor is also private). Therefore, I am not creating the object of the class, I am just accessing the methods with the class name. So, in the utility class I want to access the application.properties
. But neither @Value
nor autowiring Environment
works. It always returns null
.
Is there a way to access fields in application.properties
in a utility class? I searched for it a lot, but I didn’t find any references.