在 application.properties 中引用 VCAP 变量
referencing VCAP variables in application.properties
我的 VCAP 如下所示:
"VCAP_SERVICES": {
"rabbitmq": [
{
"credentials": {
"hostname": "10.11.241.52",
"ports": {
"15672/tcp": "52764",
"5672/tcp": "42204"
我的问题是如何在 application.properties 中引用值“52764”?请注意,我们正在构建 spring 个启动应用程序。
谢谢你和最诚挚的问候,
雅舒
在该示例中,您应该能够在 application.properties
中使用如下属性:
spring.rabbitmq.host: ${vcap.services.rabbitmq.credentials.hostname}
spring.rabbitmq.port: ${vcap.services.rabbitmq.credentials.ports.15672/tcp}
${vcap.services...}
占位符由 Spring 引导环境 post 处理器启用。 JavaDoc for that class.
中提供了一些详细信息
可以在 Spring blog post 中找到更多详细信息,以及在 Spring 应用程序中访问 VCAP_SERVICES
中的信息的一些替代方法。
我的 VCAP 如下所示:
"VCAP_SERVICES": {
"rabbitmq": [
{
"credentials": {
"hostname": "10.11.241.52",
"ports": {
"15672/tcp": "52764",
"5672/tcp": "42204"
我的问题是如何在 application.properties 中引用值“52764”?请注意,我们正在构建 spring 个启动应用程序。
谢谢你和最诚挚的问候, 雅舒
在该示例中,您应该能够在 application.properties
中使用如下属性:
spring.rabbitmq.host: ${vcap.services.rabbitmq.credentials.hostname}
spring.rabbitmq.port: ${vcap.services.rabbitmq.credentials.ports.15672/tcp}
${vcap.services...}
占位符由 Spring 引导环境 post 处理器启用。 JavaDoc for that class.
可以在 Spring blog post 中找到更多详细信息,以及在 Spring 应用程序中访问 VCAP_SERVICES
中的信息的一些替代方法。