简体   繁体   中英

Running gcp cloud funtion locally using mvn function:run with ENV variables

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?

To get the values you are passing using the -D flag , you will need to use System.getProperty() instead of System.getenv() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM