关于@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注解的实现的更多相关文章

  1. Springboot中PropertySource注解的使用

    https://blog.csdn.net/qq_30739519/article/list/3 注解 https://blog.csdn.net/qq_30739519/article/detail ...

  2. SpringBoot 中常用注解

    本篇博文将介绍几种SpringBoot 中常用注解 其中,各注解的作用为: @PathVaribale 获取url中的数据 @RequestParam 获取请求参数的值 @GetMapping 组合注 ...

  3. SpringBoot 中常用注解@PathVaribale/@RequestParam/@GetMapping介绍

    SpringBoot 中常用注解@PathVaribale/@RequestParam/@GetMapping介绍 本篇博文将介绍几种如何处理url中的参数的注解@PathVaribale/@Requ ...

  4. SpringBoot 中常用注解@Controller/@RestController/@RequestMapping的区别

    SpringBoot中常用注解@Controller/@RestController/@RequestMapping的区别 @Controller 处理http请求 @Controller //@Re ...

  5. SpringBoot 中常用注解@Controller/@RestController/@RequestMapping介绍

    原文 SpringBoot 中常用注解 @Controller/@RestController/@RequestMapping介绍 @Controller 处理http请求 @Controller / ...

  6. springboot中常用注解总结

    1.@RestController(组合注解):标注在类上,等价于@Controller和@Responsebody @Controller:将该类标记为Controller层的类,并且注入到Spri ...

  7. SpringBoot中常见注解含义总结

    @RestController @RestController被称为一个构造型(stereotype)注解.它为阅读代码的开发人员提供建议.对于Spring,该类扮演了一个特殊角色.它继承自@Cont ...

  8. SpringBoot中常用注解@Controller/@RestController/@RequestMapping的区别

    @Controller 处理http请求 @Controller //@ResponseBody public class HelloController { @RequestMapping(valu ...

  9. SpringMVC 和SpringBoot中的注解是如何起作用的,如何实现的

    SpringMVC源码解读 - HandlerMapping - RequestMappingHandlerMapping初始化   https://www.cnblogs.com/leftthen/ ...

随机推荐

  1. BMFont制作美术字体

    生成 Number.fnt.Number_0.png 两个文件,将其拖入Unity 相应位置,继续下一步 箭头所指就是我们要得到的最终目标,在文本处字体使用它就可以了. 在使用 Tools -> ...

  2. vue定义全局变量

    思路 将变量放到 window 对象上面 1.普通 创建 global.js window.a = 1; main.js 中引用 import './global.js' 实际使用 console.l ...

  3. ElasticSearch 评分排序

    背景 通过脚本改变评分 背景 近期有一个需求,需要对优惠券可用商品列表加个排序,只针对面值类的券不包括折扣券. 需求是这样的,假设有一张面值券 50 块钱,可用商品列表 A 100.B 40.C 10 ...

  4. Linux DNS 查询剖析(第四部分) | Linux 中国

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/F8qG7f9YD02Pe/article/details/82879414 在第四部分中,我将介绍容 ...

  5. ubuntu 安装jdk 的两种方式:

    :通过ppa(源) 方式安装. 2:通过官网下载安装包安装. 这里推荐第1种,因为可以通过 apt-get upgrade 方式方便获得jdk的升级 使用ppa/源方式安装 1.添加ppa sudo ...

  6. 在GDAL中添加GDALRasterizeGeometriesBuf函数

    缘起 GDAL的栅格化算法中有GDALRasterizeLayers.GDALRasterizeLayersBuf和GDALRasterizeGeometries函数,但是没有GDALRasteriz ...

  7. 单片机成长之路(avr基础篇)- 001 ISP与IAP的区别

    ISP(In-System Programming)在系统可编程,指电路板上的空白器件可以编程写入最终用户代码, 而不需要从电路板上取下器件,已经编程的器件也可以用ISP方式擦除或再编程.IAP(In ...

  8. hive SQL 行转列 和 列转行

    一.行转列的使用 1.问题 hive如何将 a       b       1a       b       2a       b       3c       d       4c       d  ...

  9. 深入了解View(一)—— measure測量流程分析

    欢迎使用Markdown编辑器写博客 本Markdown编辑器使用StackEdit改动而来,用它写博客.将会带来全新的体验哦: Markdown和扩展Markdown简洁的语法 代码块高亮 图片链接 ...

  10. paste

    echo "step 1" >> steplog.txt    echo "step 1"        sudo apt-get install ...