26.6.1 Profile-specific配置

<springProfile>标签可用于根据激活的Spring profiles,选择性的包含或排除配置片段。Profile片段可以放在<configuration>元素内的任何地方,使用name属性定义哪些profile接受该配置,多个profiles以逗号分隔。

  1. <springProfile name="staging">
  2. <!-- configuration to be enabled when the "staging" profile is active -->
  3. </springProfile>
  4. <springProfile name="dev, staging">
  5. <!-- configuration to be enabled when the "dev" or "staging" profiles are active -->
  6. </springProfile>
  7. <springProfile name="!production">
  8. <!-- configuration to be enabled when the "production" profile is not active -->
  9. </springProfile>