Alex_TD

Springboot----属性配置(properties和yaml)

1.application.properties 文件

  @Value    读取 属性

2.自定义properties文件读取:

@PropertySource("classpath:xxx.properties") 

@Value("${}")

3.application.yaml文件

@ConfigurationProperties(prefix="")

4.@PropertySource()+@ConfigurationProperties()  properties文件可以 yml不支持 @PropertySource(没用过不知道行不行)

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>

posted on 2020-02-26 23:00  Alex_TD  阅读(296)  评论(0编辑  收藏  举报