springboot中Properties注解的实现
关于@PropertySources注解的理解:http://www.imooc.com/article/252889?block_id=tuijian_wz
public interface PropertySources extends Iterable<PropertySource<?>> {
/**
* Return a sequential {@link Stream} containing the property sources.
* @since 5.1
*/
default Stream<PropertySource<?>> stream() {
return StreamSupport.stream(spliterator(), false);
}
/**
* Return whether a property source with the given name is contained.
* @param name the {@linkplain PropertySource#getName() name of the property source} to find
*/
boolean contains(String name);
/**
* Return the property source with the given name, {@code null} if not found.
* @param name the {@linkplain PropertySource#getName() name of the property source} to find
*/
@Nullable
PropertySource<?> get(String name);
这就是PropertySources的接口,那么它的实现类在哪里?是MutablePropertySources,
}
PropertySources是由工厂类生成的,看看DefaultPropertySourceFactory
public class DefaultPropertySourceFactory implements PropertySourceFactory {
@Override
public PropertySource<?> createPropertySource(@Nullable String name, EncodedResource resource) throws IOException {
return (name != null ? new ResourcePropertySource(name, resource) : new ResourcePropertySource(resource));
}
}
然后又调用ResourcePropertySource类,在该类下,实现了对配置文件的加载loadProperties(resource).
public class ResourcePropertySource extends PropertiesPropertySource {
/** The original resource name, if different from the given name. */
@Nullable
private final String resourceName;
/**
* Create a PropertySource having the given name based on Properties
* loaded from the given encoded resource.
*/
public ResourcePropertySource(String name, EncodedResource resource) throws IOException {
super(name, PropertiesLoaderUtils.loadProperties(resource));
this.resourceName = getNameForResource(resource.getResource());
}
剩下的就是java的文件的加载过程,细节就不再讨论了
springboot中Properties注解的实现的更多相关文章
- Springboot中PropertySource注解的使用
https://blog.csdn.net/qq_30739519/article/list/3 注解 https://blog.csdn.net/qq_30739519/article/detail ...
- SpringBoot 中常用注解
本篇博文将介绍几种SpringBoot 中常用注解 其中,各注解的作用为: @PathVaribale 获取url中的数据 @RequestParam 获取请求参数的值 @GetMapping 组合注 ...
- SpringBoot 中常用注解@PathVaribale/@RequestParam/@GetMapping介绍
SpringBoot 中常用注解@PathVaribale/@RequestParam/@GetMapping介绍 本篇博文将介绍几种如何处理url中的参数的注解@PathVaribale/@Requ ...
- SpringBoot 中常用注解@Controller/@RestController/@RequestMapping的区别
SpringBoot中常用注解@Controller/@RestController/@RequestMapping的区别 @Controller 处理http请求 @Controller //@Re ...
- SpringBoot 中常用注解@Controller/@RestController/@RequestMapping介绍
原文 SpringBoot 中常用注解 @Controller/@RestController/@RequestMapping介绍 @Controller 处理http请求 @Controller / ...
- springboot中常用注解总结
1.@RestController(组合注解):标注在类上,等价于@Controller和@Responsebody @Controller:将该类标记为Controller层的类,并且注入到Spri ...
- SpringBoot中常见注解含义总结
@RestController @RestController被称为一个构造型(stereotype)注解.它为阅读代码的开发人员提供建议.对于Spring,该类扮演了一个特殊角色.它继承自@Cont ...
- SpringBoot中常用注解@Controller/@RestController/@RequestMapping的区别
@Controller 处理http请求 @Controller //@ResponseBody public class HelloController { @RequestMapping(valu ...
- SpringMVC 和SpringBoot中的注解是如何起作用的,如何实现的
SpringMVC源码解读 - HandlerMapping - RequestMappingHandlerMapping初始化 https://www.cnblogs.com/leftthen/ ...
随机推荐
- beego orm 忽略字段
忽略字段 设置 - 即可忽略 struct 中的字段 type User struct { ... AnyField string `orm:"-"` ... } beego or ...
- 分享一个整理Mac储存空间的软件,有效清理xcode的垃圾
苹果的电脑还是比windows的要好,我这台用了3年时间,作为编程工作天天用,现在愣是一点儿也没有卡顿,如果换作是windows的电脑,我敢保证肯定是卡成狗,相信做编程的你肯定少补了一台mac. ma ...
- c++中函数的参数传递,内联函数和默认实参的理解
1.参数传递 1)函数调用时,c++中有三种传递方法:值传递.指针传递.引用传递. 给函数传递参数,遵循变量初始化规则.非引用类型的形参一相应的实参的副本初始化.对(非引用)形参的任何修改仅作用域局部 ...
- 硬件工程师必会电路模块之MOS管应用
实际工程应用中常用的MOS管电路(以笔记本主板经典电路为例): 学到实际系统中用到的开关电路模块以及MOS管非常重要的隔离电路(结合IIC的数据手册和笔记本主板应用电路): MOS管寄生体二极管,极性 ...
- JAVA调用外部安装7-Zip压缩和解压zip文件
1.首先在本地安装7-Zip(下载链接:https://www.7-zip.org/)2.调用7-Zip压缩.zip文件: /** * 生成.zip压缩文件 * @param fi ...
- Tomcat 9.0 安装配置
本文转自:http://blog.sina.com.cn/s/blog_15126e2170102w5o8.html 一.JDK的安装与配置 1.从官网下载jdk,注意是jdk不是jre.最好从官网下 ...
- mysql 线程等待时间,解决sleep进程过多的办法
如果你没有修改过MySQL的配置,缺省情况下,wait_timeout的初始值是28800. wait_timeout 过大有弊端,其体现就是MySQL里大量的SLEEP进程无法及时释放,拖累系统 ...
- java 定时任务之一 @Scheduled注解(第一种方法)
使用spring @Scheduled注解执行定时任务: 运行!!! 关于Cron表达式(转载) 表达式网站生成: http://cron.qqe2.com/ 直接点击 作者:http://blog ...
- Android开发导出apk报错:Unable to build: the file dx.jar was not loaded from the SDK folder
问题背景 此问题一般出现在,同时使用了Eclipse和Android Studio,eclipse是不会去下载最新的Android的相关tools,但是studio有时候会自动更新最新的build-t ...
- BizTalk Map 累积连接字符串
更多内容请查看:BizTalk动手实验系列目录 BizTalk 开发系列 BizTalk 培训/项目开发/技术支持请联系:Email:cbcye ...