Kotlin
properties class
1 |
|
1 | class) (AppProperties:: |
pom.xml
1 | <dependency> |
Example
单层属性
application-dev.properties
1 | foo.a=a |
1 |
|
嵌套多层
1 |
|
单元测试出现的问题
在单元测试中无法初始化AppProperties,原因如下:
MockMvc doesn’t use the main class, so EnableConfigurationPropertiesis not processed. MockMvc or WebMvcTest
is designed to test the web layer (duh!), not the whole app. Using either of those. the properties bean should
be set by the test.