英文:
Running gcp cloud funtion locally using mvn function:run with ENV variables
问题
我想在本地运行 Google Cloud 函数,使用以下的 Maven 插件命令:
mvn function:run
在运行时,我使用以下语法提供了一些环境变量,但是我在函数代码中无法读取这些值。系统方法 System.getenv("VAR1")
返回了空值。
mvn function:run -DVAR1=value1 -DVAR2=value2 -DrunFunction.target=com.sample.MyFunction
有人可以指导/纠正我吗?
英文:
I want to run google cloud function locally, using function maven plugin command as below
mvn function:run
While running this I am giving some env variables with below syntax but I am not able to read these values in my function code. The system method System.getenv("VAR1")
returning null value.
mvn function:run -DVAR1=value1 -DVAR2=value2 -DrunFunction.target=com.sample.MyFunction
Can anyone guide/correct me on this?
答案1
得分: 0
要获取您使用 -D
标志传递的值,您需要使用 System.getProperty()
而不是 System.getenv()
。
英文:
To get the values you are passing using the -D flag, you will need to use System.getProperty()
instead of System.getenv()
.
专注分享java语言的经验与见解,让所有开发者获益!
评论