I know how I can access the application.properties
values in @Service
classes in Java Spring boot like below
@Service
public class AmazonClient {
@Value("${cloud.aws.endpointUrl}")
private String endpointUrl;
}
But I am looking for an option to access this value directly in any class (a class without @Service annotation)
e.g.
public class AppUtils {
@Value("${cloud.aws.endpointUrl}")
private String endpointUrl;
}
But this returns null
. Any help would be appreciated.
I have already read here but didn't help.