Update 23.5. Placeholders in properties.md
parent
601d09d765
commit
1b902397ac
|
@ -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。
|
Loading…
Reference in New Issue