关于@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. Mac/Ubuntu下的数据建模工具PDMan,替代PowerDesigner

    PowerDesigner我使用过用Wine在Linux和Mac下用,但总有些缺陷,用Navicat却发觉没有Linux版本的: 一般关心的问题主要有如下: 1.数据库的关系设计图. 2.导出数据库脚 ...

  2. 更改WebBrowser控件的用户代理

    我试图在Winforms应用程序中更改WebBrowser控件的UserAgent. 我已成功使用以下代码实现此目的: [DllImport("urlmon.dll", CharS ...

  3. 前端工程化系列[05] Yeoman脚手架使用入门

    Yeoman是一款流行的前端的脚手架工具. 脚手架工具可以用来快速的自动生成项目的必要文件和基础文件结构.Yeoman使用的内建命令为yo,同时它自己也是一个包管理工具和自动化任务工具,它基于特定的模 ...

  4. 解决错误:Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.

    原因是代码直接放在默认包里边,比如src\main\java目录下 应该在src\main\java下建立子目录,比如src\main\java\com\test 这样的话,代码就在com.test这 ...

  5. Unity的RuntimeInitializeOnLoadMethod属性初探

    Unity 5.0开始增加了RuntimeInitializeOnLoadMethodAttribute,这样就很方便在游戏初始化之前做一些额外的初始化工作,比如:Bulgy参数设置.SDK初始等工作 ...

  6. 08、共享变量(Broadcast Variable和Accumulator)

    共享变量工作原理 Spark一个非常重要的特性就是共享变量.   默认情况下,如果在一个算子的函数中使用到了某个外部的变量,那么这个变量的值会被拷贝到每个task中.此时每个task只能操作自己的那份 ...

  7. iOS:UIButton扩大按钮的响应区域

    一.介绍 在开发中有时会遇见设计图里按钮设计的特别小,这时会用到手动扩大UIButton的响应范围 二.方式 下面有两个解决办法: 第一种方法:创建一个类目:UIButton+EnlargeTouch ...

  8. shell编程学习笔记(六):cat命令的使用

    这一篇不是讲shell编程的,专门讲cat命令.shell编程书用到了这个cat命令,顺便说一下cat命令. cat命令有多种用法,我一一来列举(以下蓝色字体部分为Linux命令,红色字体的内容为输出 ...

  9. Python 爬虫实例(7)—— 爬取 新浪军事新闻

    我们打开新浪新闻,看到页面如下,首先去爬取一级 url,图片中蓝色圆圈部分 第二zh张图片,显示需要分页, 源代码: # coding:utf-8 import json import redis i ...

  10. Django-ORM 复习

    老师博客 https://www.cnblogs.com/yuanchenqi/articles/6083427.html day51 表与表之间的关系 一对一 一对多(多对一) 多对多 A表依赖B表 ...