【发布时间】:2016-08-26 18:17:22
【问题描述】:
使用以下内容:
- Spring Cloud 数据流服务器 Cloudfoundry 1.0.0.RC1
- Spring Cloud 配置服务器服务
我使用附加依赖项重建了 spring-cloud-dataflow-server-cloudfoundry,以按照说明启用它与 Spring Cloud Config 服务器的绑定。它似乎按预期工作,所以这很好。
现在出现了问题,当我尝试使用我开发的自定义模块定义流时,模块的环境变量(特别是 ENCRYPT_KEY)位于我的 git 存储库中的清单 YML 文件中。
清单文件的名称是customapp-dev.yml。清单如下所示:
applications:
- name: customapp
env:
ENCRYPT_KEY: keyForEncryption
属性文件的名称是customapp-dev.properties。属性文件如下所示:
customapp.initial.context.factory=com.sun.jndi.ldap.LdapCtxFactory
customapp.ldap.provider.url=ldap://directory.xyz.com:389/dc=xyz,dc=com
customapp.username=ldap_user
customapp.password={cipher}958f87532ebba83cd81b7b0e9a0a0cc
应用程序在引导 jar 中有一个名为 application.properties 的属性文件。它看起来像这样:
spring.application.name=customapp
最后,当我部署我的流时,我在命令行中提供了一个额外的属性,如下所示:
--properties app.customapp.SPRING_PROFILES_ACTIVE=dev
跟踪应用程序部署的日志,我可以看到正在读取配置服务器实例,并且正在正确解析应用程序名称和配置文件。配置客户端正在映射 YML 清单和我的 git 存储库中的属性文件。
但是,错误表明占位符customapp.password 无法解密。
2016-08-26T13:40:46.62-0600 [APP/0] OUT . ____ _ __ _ _
2016-08-26T13:40:46.62-0600 [APP/0] OUT /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
2016-08-26T13:40:46.62-0600 [APP/0] OUT ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2016-08-26T13:40:46.62-0600 [APP/0] OUT \\/ ___)| |_)| | | | | || (_| | ) ) ) )
2016-08-26T13:40:46.62-0600 [APP/0] OUT ' |____| .__|_| |_|_| |_\__, | / / / /
2016-08-26T13:40:46.62-0600 [APP/0] OUT =========|_|==============|___/=/_/_/_/
2016-08-26T13:40:46.63-0600 [APP/0] OUT :: Spring Boot :: (v1.3.5.RELEASE)
2016-08-26T13:40:46.65-0600 [APP/0] OUT Fetching config from server at: https://config-dfcc3100-7514-47e6-b30e-a0eefcf4929d.dev.xyz.com
2016-08-26T13:40:48.13-0600 [APP/0] OUT Located environment: name=customapp, profiles=[dev, cloud], label=master, version=null
2016-08-26T13:40:48.13-0600 [APP/0] OUT Located property source: CompositePropertySource [name='configService', propertySources=[MapPropertySource [name='https://user@bitbucket.xyz.com/scm/project/app-config.git/dev/customapp-dev.yml'], MapPropertySource [name='https://user@bitbucket.xyz.com/scm/project/app-config.git/dev/customapp-dev.properties']]]
2016-08-26T13:40:48.16-0600 [APP/0] OUT Application startup failed
2016-08-26T13:40:48.16-0600 [APP/0] OUT java.lang.IllegalStateException: Cannot decrypt: key=customapp.password
如果我为已部署(崩溃)的应用程序显式设置 ENCRYPT_KEY 环境变量,并重新启动它,它可以正常启动并像魅力一样工作。
还有其他方法可以让我在部署时指定流应用程序的环境变量吗?
【问题讨论】:
标签: spring-cloud-stream spring-cloud-config spring-cloud-dataflow