如何在Spring集成xml或应用程序yml文件

时间:2017-11-21 21:57:05

标签: spring-integration cloudfoundry pcfdev

我创建了一个spring集成应用程序,并在PCF(Pivotal Cloud Foundry)环境中托管该应用程序。

让我们说我的清单文件如下:

applications:
- name: test
  memory: 1024M
  instances: 1
  domain: cfapps.pcf1.vc1.pcf.abc.com
  path: target/test-0.1.0.jar
  health-check-type: http
  health-check-http-endpoint: /health
  env:
   SPRING_LOG_LEVEL:INFO
   param1: value1
   param2: value2
   param3: value3

我的application.yml文件如下:

# default properties
logging:
level:
org.springframework.integration: $SPRING_LOG_LEVEL
endpoints:
 autoconfig.sensitive: false
 configprops.sensitive: false
 env.sensitive: false
 loggers.sensitive: false
mq:
  queues:
  validation: queue1
  authorization: queue2
  channel: channel1
  hostName: host1
  port: 100
  queueManager: QMGR
  transportType: 1
  max-concurrent-consumers: $param1
  concurrent-consumers: $param2
  max-messages-per-task: $param3
  idle-consumer-limit: 1
  idle-task-execution-limit: 1

我的问题是如何访问应用程序.yml内或MAN集成xml文件内的MANIFEST .yml文件中存在的PCF环境值,如SPRING_LOG_LEVEL,param1,param2和param3值。

如果您需要更多详细信息,请告知我们。如果我不熟悉PCF,请原谅我。

1 个答案:

答案 0 :(得分:1)

清单中的那些环境变量是运行启动应用程序的容器的真正环境变量,可以通过System.getenv或SpEL ${VARIABLE}格式进行访问。

相关问题