首页  

spring5配置属性读取机制     所属分类 spring 浏览量 1169
使用 @PropertySource 注解加载配置
@PropertySource("classpath:application.properties")


public ConfigurableEnvironment getEnvironment()

三种环境
StandardEnvironment
StandardServletEnvironment
StandardReactiveWebEnvironment

Environment 会加载 系统属性 系统环境变量 以及 自定义的配置文件

System.getProperties();
System.getenv();

String value = env.getProperty("xxx");

依次遍历 PropertySources 读取相应的配置

MapPropertySource name='systemProperties'
SystemEnvironmentPropertySource name='systemEnvironment'
ResourcePropertySource name='class path resource [application.properties]'

上一篇     下一篇
BeanFactory和ApplicationContext的区别

jvm在线诊断工具greys

.profile 与 .bash_profile

spring5模块介绍

spring aop 与 aspectj的区别和联系

基于Aspect注解的spring aop 实例