Update 23.5. Placeholders in properties.md

master
qibaoguang 2015-02-08 22:00:33 +08:00
parent 601d09d765
commit 1b902397ac
1 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,14 @@
### 23.5. 属性占位符
当application.properties里的值被使用时它们会被存在的Environment过滤所以你能够引用先前定义的值比如系统属性
```java
app.name=MyApp
app.description=${app.name} is a Spring Boot application
```
**注**你也能使用相应的技巧为存在的Spring Boot属性创建'短'变量,具体参考[Section 63.3, “Use short command line arguments”](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-use-short-command-line-arguments)。
* 使用YAML代替Properties
[YAML](http://yaml.org/)是JSON的一个超集也是一种方便的定义层次配置数据的格式。无论你何时将[SnakeYAML ](http://code.google.com/p/snakeyaml/)库放到classpath下SpringApplication类都会自动支持YAML作为properties的替换。
**注**:如果你使用'starter POMs'spring-boot-starter会自动提供SnakeYAML。