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>
原文地址:https://www.cnblogs.com/chencn/p/12369717.html