The AWS has introduced Environment variables for accessing in the Lambda function. I could not find any documentation which shows how to access the environment variables from the Lambda function using Java. Can anyone help me?
AWS已引入环境变量以便在Lambda函数中进行访问。我找不到任何文档说明如何使用Java从Lambda函数访问环境变量。谁能帮我?
2 个解决方案
#1
50
you can get them with:
你可以得到他们:
System.getenv("NAME_OF_YOUR_ENV_VARIABLE")
#2
2
If You are using Spring Core then PropertySourcesPlaceholderConfigurer class can be initialized as a part of Configuration and then @Value("${RESOURCE_URL}") annotation can be used to access environment variables.
如果您使用的是Spring Core,则可以将PropertySourcesPlaceholderConfigurer类初始化为Configuration的一部分,然后可以使用@Value(“$ {RESOURCE_URL}”)注释来访问环境变量。
@Bean
public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
@Value("${RESOURCE_URL}")
private String url;
#1
50
you can get them with:
你可以得到他们:
System.getenv("NAME_OF_YOUR_ENV_VARIABLE")
#2
2
If You are using Spring Core then PropertySourcesPlaceholderConfigurer class can be initialized as a part of Configuration and then @Value("${RESOURCE_URL}") annotation can be used to access environment variables.
如果您使用的是Spring Core,则可以将PropertySourcesPlaceholderConfigurer类初始化为Configuration的一部分,然后可以使用@Value(“$ {RESOURCE_URL}”)注释来访问环境变量。
@Bean
public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
@Value("${RESOURCE_URL}")
private String url;