一.读取方法
1. @ConfigurationProperties(推荐)
使用格式:`@ConfigurationProperties(prefix = "xxx")
2. @Value
@Value("${xxx.xxx}")
3. Environment
4. IO流
二.使用@ConfigurationProperties的前置条件
1. @Component或者@Configuration使其成为Bean类
2. 在启动类开启功能@EnableConfigurationProperties
启用对@ConfigurationProperties带注释的 Bean 的支持,方便了在每个读取类上都加上@Component
的Bean支持
3. 在启动类开启扫描@ConfigurationPropertiesScan
在启动类上加@ConfigurationPropertiesScan(basePackages = "包位置")
开启扫描