在Cloud-Foundry
中,我已将mongo-secrets
存储在CUPS
中,并且我想在Mac中本地复制相同的内容
这是两个属性
vcap.services.mongo-creds.credentials.username=**
vcap.services.mongo-creds.credentials.password=**
在使用./gradlew bootRun
在本地系统中运行我的应用程序之前,我给出了这两个命令来设置这些属性以启动应用程序
export vcap.services.mongo-creds.credentials.username=**
export vcap.services.mongo-creds.credentials.password=**
我在本地终端收到以下异常
arun$ export vcap.services.mongo-creds.credentials.username=***
-bash: export: `vcap.services.mongo-creds.credentials.username=**': not a valid identifier
arun$
我能够通过两次更正做到这一点
我将名称从mongo-creds
更改为mongoCreds
。我的Mac
终端不接受连字符
我将dot
或.
替换为underscore
或_
,例如
export vcap_services_mongoCreds_credentials_username=***
应用程序能够提取这些变量
Bash shell不允许点.
或破折号-
成为变量标识符的一部分。
因此,在您的export
表达式中,当为变量vcap.services.mongo-creds.credentials.username
定义值时,Bash会告诉您此变量的名称无效。
一个简单的解决方案是选择另一个变量名,或改用下划线_
。
但是要在Mac上具有相关的cf push
开发人员经验,我建议您使用CF Local,而不是基于简单的Gradle命令构建自己的即席设置。使用CF Local,您将能够从远程Cloud Foundry基础继承服务绑定,包括使用cf cups
创建的用户提供的服务。这应该非常适合您的用例!