简体   繁体   English

使用 mvn function 在本地运行 gcp 云功能:使用 ENV 变量运行

[英]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我想在本地运行谷歌云 function,使用 function maven 插件命令如下

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.在运行此程序时,我提供了一些具有以下语法的环境变量,但我无法在我的 function 代码中读取这些值。 The system method System.getenv("VAR1") returning null value.系统方法System.getenv("VAR1")返回 null 值。

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() .使用 -D 标志获取您传递的值,您需要使用System.getProperty()而不是System.getenv()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在本地运行 GCP DataflowTemplates - Unable to run GCP DataflowTemplates locally 如何使用Google Cloud Storage服务在本地运行Junits - How to run Junits locally using Google Cloud Storage service 运行mvn jboss-as:run时出错 - Error while running mvn jboss-as:run 无法在简单的Java程序中读取cloud Foundry env变量(不使用spring) - Unable to read cloud foundry env variables inside a simple java program (Not using spring) 无法使用 jdk 11 运行 mvn install - Unable to run mvn install using jdk 11 使用Chef在克隆的仓库上运行mvn install - Run mvn install on a cloned repo using chef 使用令牌从本地运行的Google Cloud应用程序检索Firebase用户 - Retrieve Firebase User using token, from Google Cloud application running locally 连接重置错误 - 运行 mvn clean install 以运行功能时 - Connection reset error - when running mvn clean install to run features JVM 在尝试通过运行“mvn test”运行测试时崩溃 - JVM crashing when trying to run the tests by running `mvn test` 运行mvn集成测试不会运行robotframework测试用例 - Running mvn integration-test does not run robotframework test cases
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM