2015-02-08 14:12:45 +00:00
|
|
|
|
### 23.6.3. Multi-profile YAML文档
|
|
|
|
|
|
|
|
|
|
你可以在单个文件中定义多个特定配置(profile-specific)的YAML文档,并通过一个spring.profiles key标示应用的文档。例如:
|
|
|
|
|
```json
|
|
|
|
|
server:
|
|
|
|
|
address: 192.168.1.100
|
|
|
|
|
---
|
|
|
|
|
spring:
|
|
|
|
|
profiles: development
|
|
|
|
|
server:
|
|
|
|
|
address: 127.0.0.1
|
|
|
|
|
---
|
|
|
|
|
spring:
|
|
|
|
|
profiles: production
|
|
|
|
|
server:
|
|
|
|
|
address: 192.168.1.120
|
|
|
|
|
```
|
|
|
|
|
在上面的例子中,如果development配置被激活,那server.address属性将是127.0.0.1。如果development和production配置(profiles)没有启用,则该属性的值将是192.168.1.100。
|