This is fairly straight forward, but I can't figure out what the problem is. I am trying to access environment variables from application.properties but when I do so like this:
import org.springframework.core.env.Environment;
public class MailService {
    @Autowired
    private static Environment env;
...
...
...
public static void send(){
        System.out.println("env {}" + env.getProperty("AWS_ACCESS_KEY_ID"));
}
Then I get a NullPointerException.
So what is going on? Why am I getting an error. Here is my application.properties file with fake values:
AWS_ACCESS_KEY_ID="Asdsds"
AWS_SECRET_KEY="sdsdsdsdsdsd"
 
     
    